What is HttpContext State?

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?
 
M

Matt Berther

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.
 
J

John Timney \(ASP.NET MVP\)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top