扩展方法

 public static string HeaderValue(this HttpRequest request,string headerKey)
        {
            if (request != null)
            {
                var dict = request.Headers;

                if (dict.ContainsKey(headerKey))
                {
                    var val =  dict[headerKey];
                    if (!String.IsNullOrEmpty(val))
                    {
                        return val;
                    }
                }
            }
            return "";
        }

使用:

相关文章:

  • 2021-10-03
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
  • 2021-08-29
猜你喜欢
  • 2021-11-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-12
  • 2021-12-13
  • 2021-11-01
相关资源
相似解决方案