The Global.asax file, also known as the ASP.NET application file, is an optional file that contains code for responding to application-level events raised by ASP.NET or by HttpModules and session-level events.
The following are some of the important events in the Global.asax file.
- Application_Init
- Application_Start
- Session_Start
- Application_BeginRequest
- Application_EndRequest
- Application_AuthenticateRequest
- Application_Error
- Session_End
- Application_End
The purpose of these event handlers is discussed in this section below.
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.
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 Application_EndRequest event is fired when the application terminates.
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.
Application_Start/End events are called only once.
No comments:
Post a Comment