Saturday 29 March 2014

Global.asax

Global.asax contains event handlers that are related to your applications and user sessions. Global.asax also contains an event handler that runs whenever an error happens anywhere in your application. By using Global.asax you can intercept every error that happens on your site. There are other event handlers in Global.asax that can also be useful.

Application_Start:
Runs when your site is started by the web server.

Application_End:
Runs when your site is stopped by the web server.

Application_Error:
Whenever there is a server error on your site.

Session_Start:
Runs when a user arrives at your site and start a new session.

Session_End:
Runs when a user session ends.

The most likely use of the Session_Start and Session_End events would be to log details of users when they arrive at your site.

You can also add other event handlers to Global.asax. There are many other application events that Global.asax can handle. A useful example is the Application_AuthenticateRequest event which runs before any page is served to a user, some programmers use this to implement their own custom login systems when they have special requirements that go beyond the built-in security features.

No comments:

Post a Comment