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:
- Hack in ScottGu's blog works perfect.
- Monitoring via machine.config is also great, but I prefer to log it into our log.
- As it turned out, simplest solution is to check HostingEnvironment.ShutdownReason property in my Application_End method.