The Global.asax contains two types of events those are
1. Events which are fired for every request
2. Events which are not fired for every request
Methods corresponding to events that fire on each request
1. Application_BeginRequest() – This event fired when a request for the web application comes in.
2. Application_AuthenticateRequest – This event fired just before the user credentials are authenticated. You can specify your own authentication logic over here.
3. Application_AuthorizeRequest() – This event fired on successful authentication of user’s credentials. You can use this method to give authorization rights to user.
4. Application_ResolveRequestCache() – This event fired on successful completion of an authorization request.
5. Application_AcquireRequestState() – This event fired just before the session state is retrieved for the current request.
6. Application_PreRequestHandlerExecute() – This event fired before the page framework begins before executing an event handler to handle the request.
7. Application_PostRequestHandlerExecute() – This event fired after HTTP handler has executed the request.
8. Application_ReleaseRequestState() – This event fired before current state data kept in the session collection is serialized.
9. Application_UpdateRequestCache()This event fired before information is added to output cache of the page.
10. Application_EndRequest() – This event fired at the end of each request
Methods corresponding to events that do not fire on each request
1. Application_Start() – This event fired when the first resource is requested from the web server and the web application starts.
2. Session_Start() – This event fired when session starts on each new user requesting a page.
3. Application_Error() – This event fired when an error occurs.
4. Session_End() – This event fired when the session of a user ends.
5. Application_End() – This event fired when the web application ends.
6. Application_Disposed() - This event fired when the web application is destroyed.
Adding Global.asax file:Go to Website -> Add New Item and find the icon that says Global Application Class. Add this item, and then insert the code into its text. If you are using a web application project, use the code-behind file.