- In my Dev Machine
HttpContext.Current.Request.UserHostAddress
is null. Why? how can I turn it on? - How can I get list of Ips in case of a proxy client?
WCF Service with ASP.net 4 window7.
Thanks
HttpContext.Current.Request.UserHostAddress
is null.
Why? how can I turn it on?WCF Service with ASP.net 4 window7.
Thanks
to avoid this problem you can parse the HTTP_X_FORWARDED_FOR for the last entery IP.
ip=Request.ServerVariables["HTTP_X_FORWARDED_FOR"] ;
if (!string.IsNullOrEmpty(ip))
{
string[] ipRange = ip.Split(',');
int le = ipRange.Length - 1;
string trueIP = ipRange[le];
}
else
{
ip=Request.ServerVariables["REMOTE_ADDR"];
}
Hope this will helps you