In my web application Application.End
is called after every request for some reason and the application is restarted. When I set a breakpoint in Applicaio
Tess Ferrandez wrote a good blog post on how to determine the reason for App Domain recycling. Tess has this to say on how to log the restart event:
How do you determine what caused an appdomain restart? In ASP.NET 2.0 you can use the built in Health Monitoring Events to log application restarts along with the reason for the restart. To do this you change the master web.config file in the C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG directory and add the following section
<healthMonitoring>
<rules>
<add name="Application Lifetime Events Default"
eventName="Application Lifetime Events"
provider="EventLogProvider" profile="Default" minInstances="1"
maxLimit="Infinite" minInterval="00:01:00" custom="" />
To turn on logging for IIS6 you can use:
cscript adsutil.vbs Set w3svc/AppPools/DefaultAppPool/LogEventOnRecycle 255
For IIS7 you can control it from the IIS manager - Application pools - Advanced Settings.