Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
488 views
in Technique[技术] by (71.8m points)

iis - 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. 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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: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="" />

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...