Get the client's IP address

xiaoxiao2021-03-06  57

Author: Unknown Source: Unknown Joined: 2002-12-21 Chinese House to get the IP address of the client to use Request.ServerVariables ( "REMOTE_ADDR") in ASP, but if the client is using a proxy server to access, then take to It is the IP address of the proxy server, not the real client IP address. To obtain a real IP address of the client through the proxy server, use the request.servervariables ("http_x_forwarded_for") to read. However, it is not paying attention to every proxy server to read the client's true IP with Request.ServerVariables ("http_x_forwarded_for"), and some use this method reads the IP of the proxy server. One thing to note is that if the client does not pass the proxy server to access, the value taken by Request.ServerVariables ("http_x_forwarded_for") will be empty. Therefore, if this method is to be used in the program, it can be processed: ... userip = request.serverVariables ("http_x_forwarded_for") if userip = "" "" Remote_Addr ") ... That is: If the client passes the proxy server, take the value of http_x_forwarded_for, if not through the proxy server, take the value of Remote_ADDR.

转载请注明原文地址:https://www.9cbs.com/read-114668.html

New Post(0)