biofractal
biofractal

Reputation: 19133

How do I access NancyFX Request Header values

I need to get some custom (shibboleth) header values out the Request.Headers collection. Currently I am managing to do this using the following code:

CommonName = Request.Headers["cn"].FirstOrDefault();
Email = Request.Headers["mail"].FirstOrDefault();

Is there a less cumbersome syntax to get at the header values? I was hoping to see a dynamic object, like the Query or the Form so I could use dynamic property names, something like this:

CommonName = Request.Headers.cn;
Email = Request.Headers.mail;

Thank you.

Upvotes: 8

Views: 6401

Answers (1)

Steven Robbins
Steven Robbins

Reputation: 26599

The headers is set up this way to give better strong typing support for the common headers; if you're using non-standard headers you'll get slightly uglier syntax unless you write you own wrapper around them.

Upvotes: 7

Related Questions