How to get the client IP in the ASP

xiaoxiao2021-03-06  68

Use the request.servervariables ("remote_addr") in the ASP to get the client's IP address, but if the client is using a proxy service

The device is accessed, which is taken is the IP address of the proxy server, not the real client IP address. Want to get the truth of the client through the proxy server

The IP address is read using the request.serverVariables ("http_x_forwarded_forward").

But what you have to pay attention is not every proxy server, you can read the client with Request.ServerVariables ("http_x_forwarded_for")

The real IP, some use this method is still an IP of the proxy server.

It is also something to note that if the client does not access it through the proxy server, use Request.ServerVariables

("Http_x_forwarded_for") takes the value 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 = "" "" Userip = Request.serverVariables ("remote_addr")

%>

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

New Post(0)