Wednesday, March 28, 2012

why my Application_End never get called?

I set break points at Application_Start and Application_End in Global.asax.cs file, then I start debugging my App in VS.NET, Application_Start is hit and breaks successfully. But when I shut down debugging, the break point in Application_End never get hit. Any idea why?

I added some event logging code in the Application_End method and want to debug this code. Don't know why my debugging is not working for this method.This question has been answered here:view post 669457

Quote from Link (posted bychrisri):

This event fires when a live application is gracefully shutdown. The following things can cause this event to fire:

1. You edit the config file for an application that's running. This causes ASP.NET to unload the app and reload it, so Application_End will fire

2. You change a dll in the bin directory. This also causes ASP.NET to unload the app and reload it, so Application_End will fire

3. You stop (or restart) IIS

4. If you have any sort of Process Recycling turned on either in IIS6 App Pools, or using the aspnet worker process, then when that process recycles the Application_End event will fire for all active applications

5. Any other similar event that causes processes to gracefully restart.

It does NOT fire when a process doesn't gracefully exit - like it's deadlocked and needs to be killed. Also It does NOT fire when all live sessions have ended, although all active sessions will end before the application ends in the above scenarios. The subtle difference is that all live sessions can end but the app is still running idle.

0 comments:

Post a Comment