Request.ServerVariables [“REMOTE_ADDR”]足够可靠吗?

时间:2021-11-24 02:07:03

Currently I am using Request.ServerVariables["REMOTE_ADDR"] to get the IP from the client.

目前我正在使用Request.ServerVariables [“REMOTE_ADDR”]从客户端获取IP。

What guarantees I get when calling this Method. Or should I look in other ServerVariables as well?

调用此方法时我得到了什么保证。或者我应该查看其他ServerVariables?

1 个解决方案

#1


7  

Found some really neat information on retrieving the client's IP address here.

在这里找到了一些关于检索客户端IP地址的非常简洁的信息。

Essentially, you should probably also pay attention to the Request.ServerVariables("HTTP_X_FORWARDED_FOR") as well. This helps to identify the actual IP address if the end user is going through a proxy whereas the REMOTE_ADDR attribute would be the address of the proxy...unless it is an anonymous proxy in which case, you would still just get the proxy address.

基本上,您也应该注意Request.ServerVariables(“HTTP_X_FORWARDED_FOR”)。这有助于识别最终用户通过代理时的实际IP地址,而REMOTE_ADDR属性将是代理的地址...除非它是匿名代理,在这种情况下,您仍然只需获取代理地址。

#1


7  

Found some really neat information on retrieving the client's IP address here.

在这里找到了一些关于检索客户端IP地址的非常简洁的信息。

Essentially, you should probably also pay attention to the Request.ServerVariables("HTTP_X_FORWARDED_FOR") as well. This helps to identify the actual IP address if the end user is going through a proxy whereas the REMOTE_ADDR attribute would be the address of the proxy...unless it is an anonymous proxy in which case, you would still just get the proxy address.

基本上,您也应该注意Request.ServerVariables(“HTTP_X_FORWARDED_FOR”)。这有助于识别最终用户通过代理时的实际IP地址,而REMOTE_ADDR属性将是代理的地址...除非它是匿名代理,在这种情况下,您仍然只需获取代理地址。