Describe Global.asax file in Dot Net?

The Global.asax file is in the root application directory. While Visual Studio .NET automatically inserts it in all new ASP.NET projects, it’s actually an optional file. It’s okay to delete it—if you aren’t using it. The .asax file extension signals that it’s an application file rather than an ASP.NET file that uses aspx. This file is configured so that any direct HTTP request (via URL) is rejected automatically, so users cannot download or view its contents. The ASP.NET page framework recognizes automatically any changes that are made to the Global.asax file. The framework reboots the application, which includes closing all browser sessions, flushes all state information, and restarts the application domain.
The Global.asax file, which is derived from the HttpApplication class, maintains a pool of HttpApplication objects, and assigns them to applications as needed. The Global.asax file contains the following events:

  1. Application_Init: Fired when an application initializes or is first called. It’s invoked for all HttpApplication object instances.
  2. Application_Disposed: Fired just before an application is destroyed. This is the ideal location for cleaning up previously used resources.
  3. Application_Error: Fired when an unhandled exception is encountered within the application.
  4. Application_Start: Fired when the first instance of the HttpApplication class is created. It allows you to create objects that are accessible by all HttpApplication instances.
  5. Application_End: Fired when the last instance of an HttpApplication class is destroyed. It’s fired only once during an application’s lifetime.
  6. Application_BeginRequest: Fired when an application request is received. It’s the first event fired for a request, which is often a page request (URL) that a user enters.
  7. Application_EndRequest: The last event fired for an application request.
  8. Application_PreRequestHandlerExecute: Fired before the ASP.NET page framework begins executing an event handler like a page or Web service.
  9. Application_PostRequestHandlerExecute: Fired when the ASP.NET page framework is finished executing an event handler.
  10. Applcation_PreSendRequestHeaders: Fired before the ASP.NET page framework sends HTTP headers to a requesting client (browser).
  11. Application_PreSendContent: Fired before the ASP.NET page framework sends content to a requesting client (browser).
  12. Application_AcquireRequestState: Fired when the ASP.NET page framework gets the current state (Session state) related to the current request.
  13. Application_ReleaseRequestState: Fired when the ASP.NET page framework completes execution of all event handlers. This results in all state modules to save their current state data.
  14. Application_ResolveRequestCache: Fired when the ASP.NET page framework completes an authorization request. It allows caching modules to serve the request from the cache, thus bypassing handler execution.
  15. Application_UpdateRequestCache: Fired when the ASP.NET page framework completes handler execution to allow caching modules to store responses to be used to handle subsequent requests.
  16. Application_AuthenticateRequest: Fired when the security module has established the current user’s identity as valid. At this point, the user’s credentials have been validated.
  17. Application_AuthorizeRequest: Fired when the security module has verified that a user can access resources.
  18. Session_Start: Fired when a new user visits the application Web site.
  19. Session_End: Fired when a user’s session times out, ends, or they leave the application Web site.
Tagged . Bookmark the permalink.

Leave a Reply