Does NancyFX have the equivalent of HttpRequest.ServerVariables containing X-Forwarded-For values?

I would like to determine if there is an X_FORWARDED_FOR value in a request made to my NancyFX handler. In MVC, this is stored in the ServerVariables collection named HttpRequest.

Where should I look for the same value in NancyFX?

+4
source share
1 answer

All HTTP request headers are available in your module through the Request property on the NancyModule . For instance:.

 public class MyModule : NancyModule { public MyModule() { Get["/"] =_ => Request.Headers["X-Forwarded-For"].Any() ? HttpStatusCode.OK : HttpStatusCode.BadRequest; } } 
+3
source

Source: https://habr.com/ru/post/1489078/


All Articles