Apologises if this has been answered else where, I could not find it.
道歉,如果在其他地方得到了回答,我找不到它。
In the case it has not, I am trying to find the original IP of a machine who has accessed the site.
在没有的情况下,我试图找到访问该网站的机器的原始IP。
In my basic understanding, the variable HTTP_X_FORWARDED_FOR
will display the user's IP regardless of proxy's and other filters. if this is true, I am trying to code this but I get a null string
在我的基本理解中,变量HTTP_X_FORWARDED_FOR将显示用户的IP,而不管代理和其他过滤器。如果这是真的,我正在尝试编码,但我得到一个空字符串
System.Web.HttpContext context = System.Web.HttpContext.Current;
string ipAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
Possible problems are HTTP_X_FORWARDED_FOR
doesn't appear in the HTTP HEADERS / server variable list, or I am using localhost? Using REMOTE_ADDR
, the localhost IP is displayed.
可能的问题是HTTP_X_FORWARDED_FOR没有出现在HTTP HEADERS /服务器变量列表中,或者我使用的是localhost?使用REMOTE_ADDR,将显示本地主机IP。
Am I on the right lines or is my understanding incorrect?
我是在正确的界限还是我的理解不正确?
Thanks
1 个解决方案
#1
HTTP_X_FORWARDED_FOR header usually hold proxy values so it is normal you dont see any content on your local machine since you are not going through any proxies
HTTP_X_FORWARDED_FOR标头通常包含代理值,因此您没有看到本地计算机上的任何内容是正常的,因为您没有通过任何代理
#1
HTTP_X_FORWARDED_FOR header usually hold proxy values so it is normal you dont see any content on your local machine since you are not going through any proxies
HTTP_X_FORWARDED_FOR标头通常包含代理值,因此您没有看到本地计算机上的任何内容是正常的,因为您没有通过任何代理