得到IP地址的方法是< %=Request.ServerVariables("REMOTE_ADDR")%>,但是如果客户使用的代理服务器,这样就得到了代理服务器的IP,下面是得到真实IP的代码:
function GetIp()
dim realip,proxy
realip = Request.ServerVariables(”HTTP_X_FORWARDED_FOR”)
proxy = Request.ServerVariables(”REMOTE_ADDR”)
if realip = “” then
GetIp = proxy
else
GetIp = realip
end if
end function
博客介绍了获取IP地址的常规方法,即使用 <%=Request.ServerVariables(\REMOTE_ADDR\)%> ,但该方法在客户使用代理服务器时会得到代理服务器的IP。随后给出了用ASP编写的获取真实IP地址的代码,通过函数GetIp实现。
2929

被折叠的 条评论
为什么被折叠?



