简体   繁体   English

如何找出重新启动ASP.NET Web应用程序的原因

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

In my web application Application.End is called after every request for some reason and the application is restarted. 在我的Web应用Application.End中,由于某种原因在每个请求之后调用Application.End并重新启动应用程序。 When I set a breakpoint in Applicaion_End I don't get a useful stack trace. 当我在Applicaion_End设置断点时,我没有得到有用的堆栈跟踪。 Furthermore, there are no entries in Event Viewer. 此外,事件查看器中没有条目。 According to MSDN, the following could cause an application restart: 根据MSDN,以下可能导致应用程序重新启动:

  • Adding, modifying, or deleting assemblies from the application's Bin folder. 从应用程序的Bin文件夹添加,修改或删除程序集。
  • Adding, modifying, or deleting localization resources from the App_GlobalResources or App_LocalResources folders. 从App_GlobalResources或App_LocalResources文件夹添加,修改或删除本地化资源。
  • Adding, modifying, or deleting the application's Global.asax file. 添加,修改或删除应用程序的Global.asax文件。
  • Adding, modifying, or deleting source code files in the App_Code directory. 在App_Code目录中添加,修改或删除源代码文件。
  • Adding, modifying, or deleting Profile configuration. 添加,修改或删除配置文件配置。
  • Adding, modifying, or deleting Web service references in the App_WebReferences directory. 在App_WebReferences目录中添加,修改或删除Web服务引用。
  • Adding, modifying, or deleting the application's Web.config file. 添加,修改或删除应用程序的Web.config文件。

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. 在应用程序启动时,我正在从访问数据库中读取一个值,该值会导致创建和删除.ldb文件。 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? 是否有任何日志记录导致应用程序重新启动的此类事件?

Tess Ferrandez wrote a good blog post on how to determine the reason for App Domain recycling. Tess Ferrandez撰写了一篇关于如何确定App Domain回收原因的博客文章 Tess has this to say on how to log the restart event: 苔丝有关于如何记录重启事件的话:

How do you determine what caused an appdomain restart? 你如何确定导致appdomain重启的原因? 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. 在ASP.NET 2.0中,您可以使用内置的运行状况监视事件来记录应用程序重新启动以及重新启动的原因。 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 为此,您需要更改C:\\ WINDOWS \\ Microsoft.NET \\ Framework \\ v2.0.50727 \\ CONFIG目录中的主web.config文件并添加以下部分

<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: 要打开IIS6的日志记录,您可以使用:

cscript adsutil.vbs Set w3svc/AppPools/DefaultAppPool/LogEventOnRecycle 255

For IIS7 you can control it from the IIS manager - Application pools - Advanced Settings. 对于IIS7,您可以从IIS管理器 - 应用程序池 - 高级设置控制它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM