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
标签:
asp-classic