What is HttpContext State?

  • Thread starter Thread starter ad
  • Start date Start date
A

ad

I find a line in a Web application like:
myString=(string)HttpContext.Current.Items["aString"];

I used to use
myString=(string)Application["aString"];
or
myString=(string)ViewState["aString"];

I know about the difference about Application state and ViewState.
But what is the HttpContext statae?
 
Hello ad,

HttpContext.Current is the HttpContext associated with the current request.
The Items property on this object is a collection that you can use to pass
things around for the currently executing request *only*.

So, Application is global to the entire application. ViewState is for the
current page. Session is for the current session. Finally Items is for the
current request.
 
Simply put - its the current request passing through the asp.net pipeline
and the objects that form the request, viewstate etc. forms part of the
request in this context....

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
Back
Top