Monday, March 23, 2009

Get IPADDRESS

Method 1

HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];


Method 2

string strHostName = System.Net.Dns.GetHostName();

string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();

HttpContext.Current.Request.UserHostAddress;

Method 3

Use the below code to get the IP address of the machine and not the proxy use the following code

HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_For]

No comments:

Post a Comment