Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storage medium for the lifecycle of a single request?

Im sure there was a request-wide object-based storage medium, similar to HttpContext.Current.Session, that persisted globally just for the life of a single request, but I cannot for the life of me remember it.

like image 563
maxp Avatar asked Oct 27 '11 09:10

maxp


1 Answers

I bet you're thinking of HttpContext.Items.

Gets a key/value collection that can be used to organize and share data between an IHttpModule interface and an IHttpHandler interface during an HTTP request.

Very useful for sharing state between HttpModules, HttpHandlers and pages from different parts of the request cycle.

More reading:

  • 4Guys from Rolla - HttpContext.Items - a Per-Request Cache Store

Note that HttpContext.Items works for both ASP.NET WebForms and ASP.NET MVC but it there's a caveat when using both in the same web app. More about that in this question.

like image 132
Markus Olsson Avatar answered Nov 14 '22 23:11

Markus Olsson