扩展方法
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 "";
}
使用: