- Dim strClientIP As String
- strClientIP = Request.UserHostAddress()
- Response.Write(strClientIP)
ASP .NET web services:
Context.Request.ServerVariables ["REMOTE_ADDR"]
OR
string ip;
ip=Request.ServerVariables("HTTP_X_FORWARDED_FOR");
if(ip==string.Empty)
{
ip=Request.ServerVariables("REMOTE_ADDR");
}
REMOTE_ADDR does not always provide the users IP but rather the ISPs' IP address so first test HTTP_X_FORWARDED_FOR as this one is the real user IP.
No comments:
Post a Comment