A
Adam The Generic
Hi All,
Normally i can get user IP address from the
HttpContext.Current.Request.ServerVariables, like that;
// sample
string ip;
ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(ip) || ip.Equals("unknown",
StringComparison.OrdinalIgnoreCase))
{
ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
//
but if the hosting server is behind the NAT or firewall the ServerVariables
gets only server's IP not the users.
the HttpContext.Current.Request.UserHostAddress gets the same result, just
the server IP.
How can i get the user's IP address if the hosting server is behind a
firewall or using NAT ?
Thanks in advance.
Normally i can get user IP address from the
HttpContext.Current.Request.ServerVariables, like that;
// sample
string ip;
ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(ip) || ip.Equals("unknown",
StringComparison.OrdinalIgnoreCase))
{
ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
//
but if the hosting server is behind the NAT or firewall the ServerVariables
gets only server's IP not the users.
the HttpContext.Current.Request.UserHostAddress gets the same result, just
the server IP.
How can i get the user's IP address if the hosting server is behind a
firewall or using NAT ?
Thanks in advance.