Transient state management in ASP.NET
Note: this entry has moved.
I'm reading PAG guide on
Improving .NET Application Performance and Scalability
(a must-read for every .NET developer), and I noticed they
missed one of the most interesting and useful state
management features
ASP.NET introduced, the one I call transient state.
This is the state that lives in
HttpContext.Items, which only lasts for the
duration of the current request, hence its characteristic of
"transient". It's really awesome because you can pass
information between modules, pages and controls with it, and
completely avoid Session state. It's quickly discarded as
soon as the current request has finished processing, so it
doesn't impose any of the drawbacks you need to care about
with Session.
In my experience, a combination of
HttpContext.Items and the Cache API almost
completely removes the need to use Session at all. And this
is a good thing, as you're also avoiding server affinity
resulting from inproc session state (the only one that
performs well, BTW).