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;
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