shuang121

public static string GetIP()
        {
            // 优先取得代理IP
            string userHostAddress = HttpContext.Current.Request.ServerVariables     

        ["HTTP_X_FORWARDED_FOR"];
            if (string.IsNullOrEmpty(userHostAddress))
            {
                //没有代理IP则直接取客户端IP
                userHostAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
            }
            if ((userHostAddress != null) && !(userHostAddress == string.Empty))
            {
                return userHostAddress;
            }
            return "0.0.0.0";
        }

分类:

技术点:

相关文章:

  • 2021-09-15
  • 2021-05-26
  • 2021-12-15
  • 2021-08-05
  • 2021-11-02
  • 2021-07-04
猜你喜欢
  • 2021-12-25
  • 2021-12-15
  • 2021-12-15
  • 2017-12-04
  • 2021-11-08
  • 2018-09-16
  • 2021-12-15
相关资源
相似解决方案