Email: Password:       Forgot Password 
    .netCodeSG
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.
 
TECHNOLOGIES:
 

Get IP Address of Client Machine

Article:
Viewed:  869 
Posted On:  14/02/2015 02:13:30 
How we can get the IP address of client machine in asp.net c# ? 

 

Sometime as par business requirement we need to have client machine IP address mean get the IP address of that client machine from which user is visited your web site.

To achieve this use below line of code:

        string IPAddress = string.Empty;
        IPAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
        if (IPAddress == "" || IPAddress == null)
            IPAddress = Request.ServerVariables["REMOTE_ADDR"];
 
        Response.Write("<b>Your Machine IP Address is: </b>" + IPAddress);

 

Output:

1.png

Image 1.

  Comment:
         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us