zoukankan      html  css  js  c++  java
  • 获取客户端Ip

         /// <summary>  
            /// 获取客户端Ip  
            /// </summary>  
            /// <returns></returns>  
            public static string GetClientIp()
            {
                String clientIP = string.Empty;
                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;
            }
  • 相关阅读:
    a标签去除默认样式
    js获取浏览器的get传值
    apache启动的时候报错非法协议
    获取iframe引入页面内的元素
    百度地图,画多边形后获取中心点
    echarts重写提示框信息,使提示框内的数字每3位以逗号分割
    echarts图例和图例文字位置的设置
    websocket socketJs
    winds添加静态路由
    pscp命令详解
  • 原文地址:https://www.cnblogs.com/XuPengLB/p/5689188.html
Copyright © 2011-2022 走看看