Sunday, June 5, 2011

Get Users IP Address

You can use the following :

To get the IP address of the machine and not the proxy :

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

If the above is null or empty use this code :

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

Happy coding :)

No comments:

Post a Comment