zoukankan      html  css  js  c++  java
  • Asp,net获取IP的方法

            /// <summary>
            /// 无视代理,返回真实IP
            /// </summary>
            /// <returns></returns>
            public static string GetClientIP()
            {
                if (HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null) // using proxy
                {
                    return HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].Split(new char[] { ',' })[0].ToString();  // Return real client IP.
                }
                else// not using proxy or can't get the Client IP
                {
                    return HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString(); //While it can't get the Client IP, it will return proxy IP.
                }
            }

    /// <summary>/// 无视代理,返回真实IP/// </summary>/// <returns></returns>public static string GetClientIP(){if (HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null) // using proxy{return HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].Split(new char[] { ',' })[0].ToString();  // Return real client IP.}else// not using proxy or can't get the Client IP{return HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString(); //While it can't get the Client IP, it will return proxy IP.}}

  • 相关阅读:
    source命令
    [电脑配置]屏幕扩展过,找不到界面
    [SAS]方便查询Tips
    [Excel]方便查询Tips
    [SAS]运用函数等的一些问题
    [SAS]错误整理
    [SAS]易错例子之数值型转字符型
    [R]Precedence
    [sas]Missing Value
    [SAS]
  • 原文地址:https://www.cnblogs.com/acoll/p/3722797.html
Copyright © 2011-2022 走看看