Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 231
biofractal Avatar asked Aug 06 '12 11:08

biofractal


1 Answers

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.

like image 193
Steven Robbins Avatar answered Oct 21 '22 00:10

Steven Robbins