Patrick Evers
Patrick Evers

Reputation: 33

How to create a Per Request Context for my application

I am playing around with the ASP.NET vNext. and I was wondering how to create my own context per request.

In older versions I would create a singleton and store it in HttpContext.Current.Items.

The idea is that I want to load some data at the beginning of the request that should be available through the entire request.

Upvotes: 3

Views: 1268

Answers (1)

tugberk
tugberk

Reputation: 58434

You can achieve the same with HttpContext Items. You would write a middleware like this one and you can handle your stuff inside the Invoke method.

Upvotes: 1

Related Questions