如何找出 ASP.NET Web 应用程序重新启动的原因 [英] How to find out why an ASP.NET web application is being restarted

查看:36
本文介绍了如何找出 ASP.NET Web 应用程序重新启动的原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Web 应用程序中 Application.End 因某种原因在每次请求后调用,应用程序重新启动.当我在 Applicion_End 中设置断点时,我没有得到有用的堆栈跟踪.此外,事件查看器中没有条目.根据 MSDN,以下可能会导致应用程序重新启动:

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:

  • 从应用程序的 Bin 添加、修改或删除程序集文件夹.
  • 添加、修改或删除本地化资源App_GlobalResources 或 App_LocalResources 文件夹.
  • 添加、修改或删除应用程序的 Global.asax 文件.
  • 在 App_Code 中添加、修改或删除源代码文件目录.
  • 添加、修改或删除配置文件配置.
  • 添加、修改或删除 Web 服务引用App_WebReferences 目录.
  • 添加、修改或删除应用程序的 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?

我现在通过逐步执行代码并在资源管理器中查看时间戳来解决我的问题.在应用程序启动时,我正在从导致创建和删除 .ldb 文件的访问数据库中读取值.然而,这个问题还没有得到解答.是否有任何日志记录导致应用程序重新启动的此类事件?

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?

推荐答案

Tess Ferrandez 写的很好 博文 关于如何确定应用域回收的原因.苔丝对如何记录重启事件有这样的说法:

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:

您如何确定导致 appdomain 重启的原因?在 ASP.NET 中2.0 您可以使用内置的健康监控事件来记录应用程序重新启动以及重新启动的原因.去做这您更改主 web.config 文件中C:WINDOWSMicrosoft.NETFrameworkv2.0.50727CONFIG 目录并添加以下部分

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:WINDOWSMicrosoft.NETFrameworkv2.0.50727CONFIG 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="" />

要打开 IIS6 的日志记录,您可以使用:

To turn on logging for IIS6 you can use:

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

对于 IIS7,您可以从 IIS 管理器 - 应用程序池 - 高级设置进行控制.

For IIS7 you can control it from the IIS manager - Application pools - Advanced Settings.

这篇关于如何找出 ASP.NET Web 应用程序重新启动的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆