Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Thursday 28 January 2016

HOW TO FIND CLIENT IP ADDRESS OF USER IN ASP.NET C#



Today in Engineer's World, we are discussing ASP.NET & C# query faced by a developer in very easy way. Posted By- +Manish Kumar Gautam +LIVE VIAR +ASP.NET SOLUTIONS 

Click imaginationhunt.blogspot to see latest Blogs

  
How to find client IP Address of user in Asp.net C#

Finding the User Machine IP is a very basic thing. Why would it become a necessity? It starts when a developer builds an application where they need to track the status of visitor that is viewing its application. At that, time knowing the user Machine IP becomes a matter of security and identifying the user location.

Let’s see some direct way in which we can find the IP Address.

Step-1: Create a New Website. Add a Web Form (GetIPAddress.aspx).
Step-2: Add a new Web Form. Prepare a layout design with 2 Label controls.

Click imaginationhunt.blogspot to see latest blogs

Practical Implementation:

Web Form (Source Code)

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GetIPAddress.aspx.cs" Inherits="GetIPAddress" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div style="width:190px; height:180px; border:7px groove; padding-left:20px;">
    <h3 style="color:Orange; font-weight:bold;"><u>GET IP ADDRESS</u></h3>
    <br />
        <asp:Label ID="Label1" runat="server" Text="Label-1" Font-Bold="true" ForeColor="Green"></asp:Label><br />
        <asp:Label ID="Label2" runat="server" Text="Label-2" Font-Bold="true" ForeColor="Chocolate"></asp:Label>
    </div>
    </form>
</body>
</html>

Step-3: Debug(CTRL+SHIFT+B). Check for compile error if any.
Step-4: On Build succeeded. Run(CTRL+F6).
Step-5: See the output window. Both labels are shown.


OUTPUT WINDOW:



Related Questions:


Q-1 What is IP Address?
Ans- IP stands for Internet Protocol. An Internet Protocol Address is a unique address that identifies a machine from other machines on the Internet. This protocol gives us a way to send data from one machine to another via the Internet.

Q-2 What are the possible reason to track IP of the machine?
Ans- There are various possible reasons for tracking IP of client or user Machine:
(i) To maintain security of application from untrusted users and hackers
(ii) Identifying location
(iii) It tells us, which Internet provider and internet service we are using.

Click imaginationhunt.blogspot to see latest blogs

Keep learning and sharing…

No comments:

Post a Comment

Featured post

Think that makes you rich and richer

 Napolean said: “You can think and grow rich, but if you can be brought up like most people with work and you won't starve, this wil...