how to define the IP address using classic ASP

梦想与她 提交于 2019-12-11 02:18:19

问题


I just need a fully code how to get/define the IP address for every time user login into my website because i need to save the IP address into the database table for keep track where the IP comes. Thanks.


回答1:


You're better off calling a simple function like this:

Function IP()
    Dim strIP : strIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR") 
    If strIP = "" Then strIP = Request.ServerVariables("REMOTE_ADDR")
    IP = strIP
End Function

This will return the true IP address of the user, even if they're behind a proxy or being served through a CDN which can sometimes cause an issue.




回答2:


Response.Write Request.ServerVariables ("REMOTE_ADDR")

See more at http://www.w3schools.com/asp/coll_servervariables.asp

You even could get such information: does user using proxy server, and what his real IP address (beyond proxy).

See sample: http://1click.lv/debug/debug.asp ;)




回答3:


use the Request.Servervariables Collection.

ip would be the following:

Request.ServerVariables("REMOTE_ADDR")

have a look here for a list of iis Server variables



来源:https://stackoverflow.com/questions/21131587/how-to-define-the-ip-address-using-classic-asp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!