Getting custom headers from HttpRequestMessage

Topics: Web Api
May 13, 2011 at 3:34 AM

Can anyone tell me how I can get a custom header from the HttpRequestMessage?

May 13, 2011 at 4:09 AM
RogerWilco wrote:

Can anyone tell me how I can get a custom header from the HttpRequestMessage?


HttpRequestMessage.Headers.GetValues ?

May 13, 2011 at 4:27 AM

I've just been playing around with this method and I'm still not sure about one thing.  The following works fine,

IEnumerable<string> header = requestMessage.Headers.GetValues("x-foo");
however, I always get back one string.  I'm not sure how to format the header so that the IEnumerable would return more than a single value.

May 18, 2011 at 12:13 AM

Thanks, works fine.