How to find out why an ASP.NET web application is being restarted

雨燕双飞 提交于 2020-01-28 04:59:04

问题


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 Applicaion_End I don't get a useful stack trace. Furthermore, there are no entries in Event Viewer. According to MSDN, the following could cause an application restart:

  • Adding, modifying, or deleting assemblies from the application's Bin folder.
  • Adding, modifying, or deleting localization resources from the App_GlobalResources or App_LocalResources folders.
  • Adding, modifying, or deleting the application's Global.asax file.
  • Adding, modifying, or deleting source code files in the App_Code directory.
  • Adding, modifying, or deleting Profile configuration.
  • Adding, modifying, or deleting Web service references in the App_WebReferences directory.
  • Adding, modifying, or deleting the application's Web.config file.

I guess that my code changes some file which triggers an application restart. Is there any way to find out what exactly causes the application restarts?

Edit: I solved my problem now by stepping through the code and watching the timestamps in Explorer. On application startup I'm reading a value from an access database which causes a .ldb file to be created and deleted. However, this question has not been answered yet. Is there any log that keeps record of such events that cause the application to be restarted?


回答1:


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.



来源:https://stackoverflow.com/questions/8678024/how-to-find-out-why-an-asp-net-web-application-is-being-restarted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!