【发布时间】:2017-01-24 08:10:47
【问题描述】:
当我使用此方法获得标头键名称时,我能够一一获取请求标头
private string GetHeader(string Name)
{
IEnumerable<string> headerValues;
if (Request.Headers.TryGetValues(Name, out headerValues))
{
return headerValues.FirstOrDefault();
}
else { return ""; }
}
但我真正想要的是获取所有请求标头并将它们存储在字典中,就像这样
Dictionary<string, string> ss = Request.Headers.ToDictionary(a => a.Key, a => a.Value);
//this doesn't work
有人知道怎么做吗?
【问题讨论】:
标签: c# asp.net-web-api2