Interviews2 answers
When are Application_Start() and Application_End() Used?
2 Answers
It is by default feature in Global.ascx file.
Ketan ShindePosted Nov 20, 2018, 11:49 PM EST
These two methods will declare in Global.asax file as shown below
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
//Any Initializations of resources before calling any functionality
}
protected void Application_End()
{
//Release of resources before unloading the application
}
}
Application_Start() method is called when the first resource of the application is requested and it is called once for the application. There is no “user perspective” in this. Just load/create stuff needed for the application to function.
Similarly, Application_End() method is called only once, before the application is unloaded. Use it to dispose of resources.
Sai Kumar KoonaPosted Aug 18, 2018, 3:36 AM EDT
