ASP.NET Core Equivalent to OwinContext.Environment?
ASP.NET Core Equivalent to OwinContext.Environment?
I am trying to port over some Owin middleware that uses OwinContext.Environment. I know I can support the old Owin stuff using the AspNetCore.Owin nuget package but since owin is now integrated into ASP.NET Core, I'd like to update it all.
I know the Environment Property is just a IDictionary, but what I'm unsure of is what, if anything, is special about that object as far as the context is concerned, scoping, lifetime, etc. Looking at the source code it looks like it's little more than a public virtual on the OwinContext class with a private setter. Implementing similar functionality in .net core obviously wouldn't need all of the other key value pairs that the old Owin context used, because well it doesnt exist anymore. So it seems like it would be relatively easy to replicate that functionality.
That said, Im just trying to figure out if there ise anything else in .net core that might provide similar functionality, or do I need to roll my own?
1 Answer
1
The environment in OWIN is equivalent to the HttpContext in ASP.NET Core. Instead of a weakly typed dictionary there's a type. For storing "extra stuff", you can use HttpContext.Items.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
It's pretty trivial to add header information to the request or response. The OWIN Environment is just a key value pair of strings that you could handle. owin.org/spec/spec/owin-1.0.0.html#_3.2._Environment --- I'm not sure if there is any library that does JUST environment headers, though...
– Svek
Jun 29 at 19:29