Getting custom headers from HttpRequestMessage

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

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

May 13, 2011 at 3: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 3: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 17, 2011 at 11:13 PM

Thanks, works fine.