Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to discover the reason of ASP.NET application restart

Tags:

Is there a way to monitor (log) the reason for restarting of an ASP.NET application?

We now having problem with rather complex site. It's restarting during file upload. Not on every file, but on every 5th-10th for sure. We use custom VirtualPathProvider, so this could be a reason. We also have a background worker threads, and this also could be a reason. It would be great to just know the reason.

Problem occurs on XP (IIS 5.1) and Windows Server 2003 (IIS 6).

Resolution:

Thanks guys, we've managed to catch it. It is caused by max recompilations reached. Most likely the problem is in our VirtualPathProvider, but this is completely different question.

Summary of approaches:

  1. Hack in ScottGu's blog works perfect.
  2. Monitoring via machine.config is also great, but I prefer to log it into our log.
  3. As it turned out, simplest solution is to check HostingEnvironment.ShutdownReason property in my Application_End method.
like image 217
XOR Avatar asked May 06 '09 12:05

XOR


People also ask

Why does IIS need to be restarted?

History of the IISRESET command With IIS 5.0 and earlier versions of IIS, the web server was a monolithic single process. The IIS restart command was needed for restarting the web server process to resolve performance issues that may have developed in the application.


2 Answers

Have you looked at the logging suggestions from "Logging ASP.NET Application Shutdown Events "? That would be my suggestion for a way to get more information about what is happening.

like image 180
JB King Avatar answered Nov 01 '22 02:11

JB King


Adding or removing folders inside the applicaton folder will cause the app pool to recycle (the most likely reason in your case), along with many other things. Here's an interesting article:

http://blogs.msdn.com/johan/archive/2007/05/16/common-reasons-why-your-application-pool-may-unexpectedly-recycle.aspx

on the same site is some good hints on how to monitor the restarts which is what you were actually asking. The choices are web.config and EventViewer or Performance Monitor.

http://blogs.msdn.com/johan/archive/2008/02/18/monitoring-application-pool-and-application-restarts.aspx

like image 40
hollystyles Avatar answered Nov 01 '22 01:11

hollystyles