This article details the asp.net global program file Global.asax usage, share for everyone reference. The specific analysis is as follows:
Generally speaking, a asp.net application can have only one Global.asax file, which supports many items. The specific analysis is as follows:
Application_Start: Called when the application receives the first request, which is the ideal place to assign values to application-level variables in an application or to specify the state that must be maintained for all users.
Session_Start: Similar to the Application_Start event, this event is invoked the first time a user accesses an application. For example, the Application_Start event fires only when the first request is received, the first request runs the application, and the Session_Start event is invoked the first time each end user makes a request to the application.
Application_BeginRequest: It is not listed in the templates provided by Visual Studio, but the event is triggered before each request is issued. That is, the Application_BeginRequest event is triggered before the request arrives at the server and processed before the request is processed.
application_authenticaterequest: Each request triggers the event, allowing custom authentication to be established for the request.
Application_Error: Triggered when an error is thrown by the user of the application. It is appropriate to provide application-level error handling or to log errors to the server's event log.
Session_End: When running in InProc mode, this event is triggered when the end user exits the application.
Application_End: Triggered at the end of the application. This event is not used by most asp.net developers because ASP.net completes the task of shutting down and cleaning up the remaining objects.
I hope this article will help you with the ASP.net program design.