Using the IP address to work out location

Feb 8, 2007 at 4:00 AM
I know that the IP address can be used to determine the country that the IP is in. Does anyone know how ASP.NET code can access the IP of a user?
Feb 8, 2007 at 4:10 AM
To get the IP address

HttpContext.Current.Request.UserHostAddress;

HttpContext.Current.Request.ServerVariables"REMOTE_ADDR";


To get the IP address of the machine and not the proxy use the following code

HttpContext.Current.Request.ServerVariables"HTTP_X_FORWARDED_FOR";