Request.ServerVariables("REMOTE_ADDR") can be used to retrieve the IP address of the client machine.
While clients connect internet via a proxy server, the above method only return the IP address of the proxy server, other than the REAL IP address of the client machine. In order to request the TRUE IP address of the client via the proxy server, you may use
Request.ServerVariables("HTTP_X_FORWARDED_FOR").
One more thing, if the client does not connect the internet via a proxy server, then Request.ServerVariables ("HTTP_X_FORWARDED_FOR") will return a null value. Therefore, you can use this method in your program like this:
i.e. If client connect the internet via a proxy server, we take the value returned by
HTTP_X_FORWARDED_FOR, otherwise we take the value returned by REMOTE_ADDR
While clients connect internet via a proxy server, the above method only return the IP address of the proxy server, other than the REAL IP address of the client machine. In order to request the TRUE IP address of the client via the proxy server, you may use
Request.ServerVariables("HTTP_X_FORWARDED_FOR").
One more thing, if the client does not connect the internet via a proxy server, then Request.ServerVariables ("HTTP_X_FORWARDED_FOR") will return a null value. Therefore, you can use this method in your program like this:
Code: ASP
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then
userip = Request.ServerVariables("REMOTE_ADDR")
End if
HTTP_X_FORWARDED_FOR, otherwise we take the value returned by REMOTE_ADDR
zhangao0086
likes this

