Brandon
Brandon

Reputation: 878

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?

Upvotes: 2

Views: 3282

Answers (1)

davidfowl
davidfowl

Reputation: 38804

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.

Upvotes: 7

Related Questions