4

In theory the OwinContext environment should have access to the request/response information as well as server variables, although for some reason from the OwinContext I can't access some of the custom server variables that are available from the Request.ServerVariables collection.

What is causing this discrepancy and how should I get around it?

Pierluc SS
  • 3,138
  • 7
  • 31
  • 44

1 Answers1

6

I just ran into this myself. It turns out you can access a HttpContextWrapper from the IOwinContext.Environment:

var httpContextWrapper = owinContext.Environment["System.Web.HttpContextBase"] as HttpContextWrapper;

Then you can access the Request property:

httpContextWrapper.Request.ServerVariables
Evan Mulawski
  • 54,662
  • 15
  • 117
  • 144
  • I am not sure which one is honestly better, but HttpContext.Current.Request worked as well in that context. – Pierluc SS Jun 16 '15 at 12:18