How to get a strongly typed header class from the System.Net.Http.Headers namespace from an ASP.NET kernel controller? Request.Headers is available in the controller received from the Controller , but it simply returns an IHeaderDictionary . There is also the HeaderDictionaryTypeExtensions.GetTypedHeaders extension HeaderDictionaryTypeExtensions.GetTypedHeaders , but it returns RequestHeaders , which only has specific headers. The HttpRequestHeaders has the most comprehensive list of headers, but it is unclear how to access it.
For example, how would you get an AuthenticationHeaderValue ? One parameter is AuthenticationHeaderValue.Parse(Request.Headers["Authorization"]) , but this requires strong encoding of the header name. Perhaps there is a hard-coded way to get to HttpRequestHeaders.Authorization .
Edward brey
source share