In a web application, events can occur at 3 levels
1. At the Application Level(Example: Application Start, End, Error)
2. At the Page Level(Example: Page Load)
3. At the Control Level (Example: Button Click)
In an ASP.NET web application, Global.asax file contains these Five (5) application level events.
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
In general, Application events are used to initialize data that needs to be available to all the current sessions of the application. Whereas Session events are used to initialize data that needs to be available only for a given individual session, but not between multiple sessions.
1. At the Application Level(Example: Application Start, End, Error)
2. At the Page Level(Example: Page Load)
3. At the Control Level (Example: Button Click)
In an ASP.NET web application, Global.asax file contains these Five (5) application level events.
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
In general, Application events are used to initialize data that needs to be available to all the current sessions of the application. Whereas Session events are used to initialize data that needs to be available only for a given individual session, but not between multiple sessions.
No comments:
Post a Comment