Major events in Global.Asax file?
The Global.asax file contains code for responding to application-level events raised by ASP.NET or by HttpModules. It is located in the root directory of an ASP.NET application. This file contains code that is executed in response to application-level and session-level events raised by ASP.NET or by HTTP modules.
The following are some of the important events in the Global.asax file:
- Application_Init : The Application_Init event is fired when an application initializes the first time.
- Application_Start : The Application_Start event is fired the first time when an application starts.
- Application_AuthorizeRequest: Fired when the security module has verified that a user can access resources.
- Application_ResolveRequestCache : Fired on successful completion of an authorization request.
- Application_Disposed: Fired just before an application is destroyed. This is the ideal location for cleaning up previously used resources.
- Session_Start : The Session_Start event is fired the first time when a user’s session is started. This typically contains for session initialization logic code.
- Application_BeginRequest: The Application_BeginRequest event is fired each time a new request comes in
- Application_EndRequest : The last event fired for an application request.
- Application_AuthenticateRequest : The Application_AuthenticateRequest event indicates that a request is ready to be authenticated. If you are using Forms Authentication, this event can be used to check for the user's roles and rights.
- Application_Error : The Application_Error event is fired when an unhandled error occurs within the application.
- Session_End : The Session_End Event is fired whenever a single user Session ends or times out.
- Application_End : The Application_End event is last event of its kind that is fired when the application ends or times out. It typically contains application cleanup logic.
The Global.asax file is optional. If you do not define the file, the ASP.NET page framework assumes that you have not defined any application or session event handlers.