1、取远程用户IP地址
String user_IP
=
Request.ServerVariables[
"
REMOTE_ADDR
"
].ToString();
2、穿过代理服务器取远程用户真实IP地址:
if
(Request.ServerVariables[
"
HTTP_VIA
"
]
!=
null
){
string
user_IP
=
Request.ServerVariables[
"
HTTP_X_FORWARDED_FOR
"
].ToString();
}
else
{
string
user_IP
=
Request.ServerVariables[
"
REMOTE_ADDR
"
].ToString();
}