Understanding Session_OnStart and Application_OnStart

Understanding Session_OnStart and Application_OnStart


I am confused regarding the Application_OnStart and Session_OnStart events in the global.asa file. What I feel is that the application_onstart event is triggered the very first time the application is used and the session_onstart event is triggered every time a user is logged onto the application. Can you please clarify?


As a loose analogy, the application referred here is your Web site itself, while the session is one browser’s visit. Once you stop and start your Web site, the first visitor to the Web site fires the Application_OnStart event. The first time a user hits your Web site, whether he is the first visitor or not, the Session_OnStart fires.

So, for your very first visitor after you start your Web site, both the Application_OnStart and the Session_OnStart events fire. For every other visitor after that, the Session_OnStart will fire, and not the Application_OnStart. If you stop and start your Web site (services), then the cycle will be repeated.


Share the Post: