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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With