asp中得到真正ip

来源:互联网 发布:淘宝网针织长款马甲 编辑:程序博客网 时间:2024/05/05 12:09

得到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