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

Get IP Address of Client Machine

Viewed:  1728 
Posted On:  14/02/2015 02:13:30 
How we can get the IP address of client machine in 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);




Image 1.

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