您的位置:首页 > 其它

PublicFunction

2016-07-11 11:06 323 查看
GetUserIP

public static string GetUserIP() {
String clientIP = "";
if (System.Web.HttpContext.Current != null) {
clientIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(clientIP) || (clientIP.ToLower() == "unknown")) {
clientIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_REAL_IP"];
if (string.IsNullOrEmpty(clientIP)) {
clientIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
} else {
clientIP = clientIP.Split(',')[0];
}
}
return clientIP;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: