During the application life cycle, the application raises events that you can handle and calls particular methods that you can override. To handle application events or methods, we can create a file named Global.asax in the root directory of your application.
If we create a Global.asax file, ASP.NET compiles it into a class derived from the HttpApplication class, and then uses the derived class to represent the application.
ASP.NET automatically binds application events to handlers in the Global.asax file using the naming convention Application_event, such as Application_BeginRequest.
The Application_Start and Application_End methods are special methods that do not represent HttpApplication events. ASP.NET calls them once for the lifetime of the application domain, not for each HttpApplication instance.
Below is the commonly used events and methods during the application life cycle :-
Called when the first resource (such as a page) in an ASP.NET application is requested. The Application_Start method is called only one time during the life cycle of an application.
You can use this method to perform startup tasks such as loading data into the cache and initializing static values.You should set only static data during application start. Do not set any instance data because it will be available only to the first instance of theHttpApplication class that is created.
2) Application_event :-
Raised at the appropriate time in the application life cycle.
Application_Error can be raised at any phase in the application life cycle.
Application_EndRequest is the only event that is guaranteed to be raised in every request, because a request can be short-circuited.
Called once for every instance of the HttpApplication class after all modules have been created.
Called before the application instance is destroyed. You can use this method to manually release any unmanaged resources. For more information, see Cleaning Up Unmanaged Resources.
5) Application_End :-
Called once per lifetime of the application before the application is unloaded.
Reference :- http://msdn.microsoft.com/en-us/library/ms178473(v=vs.100).aspx
Programming is Easy…..