加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

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

发布时间:2020-12-16 00:07:05 所属栏目:asp.Net 来源:网络整理
导读:在我的Web应用程序中,由于某种原因在每个请求之后调用Application.End并重新启动应用程序.当我在Applicaion_End中设置断点时,我没有得到有用的堆栈跟踪.此外,事件查看器中没有条目.根据MSDN,以下可能导致应用程序重新启动: Adding,modifying,or deleting as
在我的Web应用程序中,由于某种原因在每个请求之后调用Application.End并重新启动应用程序.当我在Applicaion_End中设置断点时,我没有得到有用的堆栈跟踪.此外,事件查看器中没有条目.根据MSDN,以下可能导致应用程序重新启动:
  • Adding,modifying,or deleting assemblies from the application’s Bin
    folder.
  • Adding,or deleting localization resources from the
    App_GlobalResources or App_LocalResources folders.
  • Adding,or deleting the application’s Global.asax file.
  • Adding,or deleting source code files in the App_Code
    directory.
  • Adding,or deleting Profile configuration.
  • Adding,or deleting Web service references in the
    App_WebReferences directory.
  • Adding,or deleting the application’s Web.config file.

我想我的代码会更改一些触发应用程序重启的文件.有没有办法找出导致应用程序重新启动的确切原因?

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

解决方法

Tess Ferrandez写了一篇关于如何确定App Domain回收原因的 blog post. Tess如何记录重启事件:

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

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读