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;
}
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;
}
相关文章推荐
- Eclipse配置PyDev插件
- PHP针对字符串开头和结尾的判断方法
- 普通用户启动nginx
- 利用简单工具进行客观视频质量分析
- JavaScript改变图片透明度,鼠标放上渐渐显示
- JavaScript图片放大
- mysql 5.7忘记密码处理
- Matlab学习(四)
- HDU1251
- SVM中SMO算法的实现理论+代码
- lucene源码分析---1
- 自定义Cell中按钮的点击事件
- Shell脚本中计算字符串长度的5种方法
- RTP包里面得到H.264数据和AAC数据的方法
- Core Data 学习:轻量级版本迁移(Lightweight Migration)
- Matlab学习(三)
- Hadoop & HBase 故障排除
- 性能测试中用LambdaProbe监控Tomcat
- 浅谈Java设计模式(二十)状态模式(State)
- JavaScript 由左向右的图片渐变过渡