WebAPi 获取请求头中对应键值

1、枚举类型  IEnumerable

public static string GetHeader(HttpRequestMessage request, string key)
{
     IEnumerable<string> keys = null;
     if (!request.Headers.TryGetValues(key, out keys))
        return null;
    return keys.First();
}    

 

posted @ 2022-05-11 19:24  陈醋当墨写尽人生酸楚  阅读(385)  评论(0编辑  收藏  举报