what is the difference between HttpApplication, HttpApplicationstate and Applicaton object. Similarly in session state and its related classes(httpsession, httpsessionstate, session object)
Application is an instance of HttpApplicationState and is a legacy way of maintaining application-wide state. It's legacy because it was the main way in classic ASP to maintain state, but in .NET you have so many other more modern ways.
HttpApplication is the class that the code in global.asax derives from and represents the runtime object that manages processing in the http pipeline for HTTP requests at runtime.
One thing that it always good to remember with this, given the appalling naming, is that you only get one HttpApplicationState (Application) object to play with. So it's fraught with things like threading issues, if you decide to maintain "global" variables
in it. it's also very fragile, as it's held in memory, so when the worker process rolls over - as it will regularly - anything stored in it will be lost. And as it's held in memory, if you run a web farm or web garden, each instance will get its own HttpApplicationState
and they will thus be out of sync with each other if you store data in them.
Which is why Brock's wonderful hint, "It's legacy...", basically means that we don't use it very much (at least for bigger applications that we actually care about).
HttpApplication, on the other hand, is an interesting beast. There is a tendency in developers that are new to ASP.NET to think that there will be one HttpApplication object: there is not. ASP.NET will spin up a number of these to enable multiple requests
to be handled in parallel. What happens with HttpApplication is that they are used and cached by a factory that lends one out to deal with each request: in other words, each request gets to use a single HttpApplication object for the duration of its request.
it is this HttpApplication object that fires the events, such as BeginRequest, AuthorizeRequest, EndRequest and so on, that the Http Modules (the things that implement IHttpModule and provide services such as authentication, caching, session and so on) get
to see.
There's a very old, but good, introduction to the ASP.NET pipeline at http://msdn.microsoft.com/en-us/magazine/cc188942.aspx. It's worth a read.
(Or better still, book a place on one of Brock's ASP.NET or ASP.NET MVC classes. Not only is he an awesome instructor that can teach you lots, he regularly buys the entire class dinner!)
(Or better still, book a place on one of Brock's ASP.NET or ASP.NET MVC classes. Not only is he an awesome instructor that can teach you lots, he regularly buys the entire class dinner!)
Thanks for the plug, but unfortunately I only buy drinks not an entire dinner :)
venki86_ece
Member
5 Points
8 Posts
HttpApplication, HttpApplicationstate and Applicaton object
Mar 17, 2012 04:20 PM|LINK
what is the difference between HttpApplication, HttpApplicationstate and Applicaton object. Similarly in session state and its related classes(httpsession, httpsessionstate, session object)
BrockAllen
All-Star
27434 Points
4891 Posts
MVP
Re: HttpApplication, HttpApplicationstate and Applicaton object
Mar 17, 2012 04:33 PM|LINK
Application is an instance of HttpApplicationState and is a legacy way of maintaining application-wide state. It's legacy because it was the main way in classic ASP to maintain state, but in .NET you have so many other more modern ways.
HttpApplication is the class that the code in global.asax derives from and represents the runtime object that manages processing in the http pipeline for HTTP requests at runtime.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
roopeshreddy
All-Star
20135 Points
3323 Posts
Re: HttpApplication, HttpApplicationstate and Applicaton object
Mar 18, 2012 11:54 AM|LINK
Hi,
HttpApplication is the base class and has properties, methods and events which are common to ASP.NET application!
HttpApplicationState is the class to store information at application level! Ex: Company Information.
Application, i can say as synonym to the HttpApplicationState, which is accessible from the Page object - Page.Application
Regrading Sessions, System.Web.SessionState namspace which contains classes to provide session wide storing of values!
The keyword which you mentioned has the same meaning!
Hope it helps u...
Roopesh Reddy C
Roopesh's Space
DMW
All-Star
15943 Points
2353 Posts
Re: HttpApplication, HttpApplicationstate and Applicaton object
Mar 19, 2012 05:59 PM|LINK
First up, Brock's absolutely correct (as always). Yay. Go, Brock, go!
One thing that it always good to remember with this, given the appalling naming, is that you only get one HttpApplicationState (Application) object to play with. So it's fraught with things like threading issues, if you decide to maintain "global" variables in it. it's also very fragile, as it's held in memory, so when the worker process rolls over - as it will regularly - anything stored in it will be lost. And as it's held in memory, if you run a web farm or web garden, each instance will get its own HttpApplicationState and they will thus be out of sync with each other if you store data in them.
Which is why Brock's wonderful hint, "It's legacy...", basically means that we don't use it very much (at least for bigger applications that we actually care about).
HttpApplication, on the other hand, is an interesting beast. There is a tendency in developers that are new to ASP.NET to think that there will be one HttpApplication object: there is not. ASP.NET will spin up a number of these to enable multiple requests to be handled in parallel. What happens with HttpApplication is that they are used and cached by a factory that lends one out to deal with each request: in other words, each request gets to use a single HttpApplication object for the duration of its request. it is this HttpApplication object that fires the events, such as BeginRequest, AuthorizeRequest, EndRequest and so on, that the Http Modules (the things that implement IHttpModule and provide services such as authentication, caching, session and so on) get to see.
There's a very old, but good, introduction to the ASP.NET pipeline at http://msdn.microsoft.com/en-us/magazine/cc188942.aspx. It's worth a read.
(Or better still, book a place on one of Brock's ASP.NET or ASP.NET MVC classes. Not only is he an awesome instructor that can teach you lots, he regularly buys the entire class dinner!)
Dave
BrockAllen
All-Star
27434 Points
4891 Posts
MVP
Re: HttpApplication, HttpApplicationstate and Applicaton object
Mar 19, 2012 06:09 PM|LINK
Thanks for the plug, but unfortunately I only buy drinks not an entire dinner :)
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/