Application refers to global application state in Classic ASP. Application is really a global dictionary object that was introduced in Classic ASP for lack of any global variables.
ASP.Net uses ApplicationIntance property to refer to application instance that is processing current request. Application instances are thread safe hence it is not required to lock the non static members. ASP.Net has Application object purely for backword compatibility so that you can easily migrate a Classic ASP application to ASP.Net. It is recommended that you store data in static members of the application class instead of in the Application object. This increases performance because you can access a static variable faster than you can access an item in the Application dictionary.
You can use following guidelines when accessing non static members in ASP.Net
ASP.Net uses ApplicationIntance property to refer to application instance that is processing current request. Application instances are thread safe hence it is not required to lock the non static members. ASP.Net has Application object purely for backword compatibility so that you can easily migrate a Classic ASP application to ASP.Net. It is recommended that you store data in static members of the application class instead of in the Application object. This increases performance because you can access a static variable faster than you can access an item in the Application dictionary.
You can use following guidelines when accessing non static members in ASP.Net
- From the Global.asax, use the this or Me object.
- From a page, every page includes a strongly-typed ApplicationInstance property.
- From the HttpContext object, use the HttpContext.ApplicationInstance property (which you type as HttpApplication)
Comments