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

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

问题描述

在我的web应用程序 Application.End 由于某种原因每个请求后调用和重新启动应用程序。当我设置在 Applicaion_End 断点我没有得到一个有用的堆栈跟踪。此外,还有在事件查看没有条目。根据MSDN,下面可能会导致应用程序重新启动:


  

      
  • 添加,修改或删除组件从应用程序的Bin
      夹。

  •   
  • 添加,修改或删除从本地化资源
      App_GlobalResources文件或App_LocalResources文件夹。

  •   
  • 添加,修改或删除应用程序的Global.asax文件。

  •   
  • 添加,修改或删除源$ C ​​$ C文件中APP_ code
      目录。

  •   
  • 添加,修改或删除配置文件配置。

  •   
  • 添加,修改或删除在Web服务引用
      App_WebReferences。目录

  •   
  • 添加,修改或删除应用程序的Web.config文件。

  •   

我想,我的code更改某些文件,它触发重新启动应用程序。有什么办法,找出到底是什么导致了应用程序重新启动?

编辑:现在我解决我的问题通过了code步进,看在资源管理器中的时间戳。在应用程序启动时我读从中会导致创建和删除一个.ldb文件的访问数据库中的值。然而,这个问题尚未解答。是否有保留,导致重新启动应用程序这样的事件记录任何日志?


解决方案

苔丝Ferrandez写了一个良好的<一个href=\"http://blogs.msdn.com/b/tess/archive/2006/08/02/asp-net-case-study-lost-session-variables-and-appdomain-recycles.aspx\"相对=nofollow>博客文章对如何确定应用程序域回收的原因。苔丝有这样一段有关如何登录重启事件说:


  

你如何确定是什么原因造成的AppDomain重新启动?在ASP.NET
  2.0你可以使用内置的健康监测活动登录应用程序重新启动与重启的原因一起。去做
  这个你更改主web.config文件
  C:\\ WINDOWS \\ Microsoft.NET \\框架\\ V2.0.50727 \\ config目录,并添加
  以下部分


 &LT; healthMonitoring&GT;
  &LT;规则与GT;
    &LT;添加名称=应用程序生命周期事件默认
         eventName的=应用程序生命周期事件
         供应商=EventLogProvider配置文件=默认minInstances =1
         MAXLIMIT =无限minInterval =00:01:00定制=/&GT;

要启用日志记录对于IIS6你可以使用:

  CSCRIPT adsutil.vbs设置W3SVC / AppPools /默认应用/ 255的LogEventOnRecycle

有关IIS7您可以从IIS管理器控制它 - 应用程序池 - 高级设置

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?

解决方案

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.

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

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