This article introduces how to obtain real IP addresses in ASP. Let’s take a look at the detailed tutorial below. Friends who need it can refer to it.
Use Request.ServerVariables("REMOTE_ADDR") in ASP to obtain the client's IP address, but if the client uses a proxy server to access it, the IP address of the proxy server is obtained, not the real client IP address. To obtain the client's real IP address through the proxy server, you must use Request.ServerVariables("HTTP_X_FORWARDED_FOR") to read it.
However, it should be noted that not every proxy server can use Request.ServerVariables("HTTP_X_FORWARDED_FOR") to read the client's real IP, and some of the IPs read in this way are still the proxy server's IPs.
Another thing to note is that if the client is not accessed through the proxy server, the value obtained with Request.ServerVariables("HTTP_X_FORWARDED_FOR") will be empty. Therefore, if you want to use this method in your program, you can handle it like this:
......
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then userip = Request.ServerVariables("REMOTE_ADDR")
......
That is: if the client passes through a proxy server, it takes the value of HTTP_X_FORWARDED_FOR, and if it does not pass through a proxy server, it takes the value of REMOTE_ADDR.
The above is an introduction to how to obtain real IP addresses in ASP. I hope the relevant knowledge and information compiled by the editor will be helpful to you. For more content, please continue to pay attention to the website of the Wuxin Technology Channel!