Get ip address in asp.net using c# | how to get ip

//To get the ip address of the machine and not the proxy use the following code
string strIPAddress = Request.UserHostAddress.ToString();
strIPAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

if (strIPAddress == null || strIPAddress == "")
{
strIPAddress = Request.ServerVariables["REMOTE_ADDR"].ToString();
}

0 comments:

Post a Comment