How to Catch if App End due to Application Pool Recycle or Idle-Timeout on Application_End RRS feed

  • Question

  • User-943250815 posted

    Is there a way to know if my website got down due to Application Pool Recycle or Idle-Timeout?

    The idea is register in a log file what caused website shutdown, my global.asax already register a shutdown at Application_End, and would like register when down due
    AppPool Recycle or Idle-Timeout.

    Thursday, October 11, 2018 11:40 PM

All replies

  • User-943250815 posted

    After some more research, found what can fit my needs.
    ApplicationShutdownReason Enum returned by System.Web.Hosting.HostingEnvironment.ShutdownReason

    As far Enum covers all AppDomain Shutdown Reason, there is no specific AppPool Recycle or Idle-Timeout, in my tests found that any change in AppPool (config values or state) causes return ShutdownReason = HostingEnvironment

    Friday, October 12, 2018 4:02 PM
  • User-271186128 posted

    Hi jzero,

    Please refer to Jani's reply in this thread:

    There is an application pool shutdown time limit in iis. Let's say it's 60 seconds and in shared hosting environment there is an application pool memory limit. Your application pool reaches this limit and iis tells the application pool to finish all the work with current requests. If all the requests finish processing before 60 seconds is passed, application_end will trigger and application pool will gracefully shut itself down. However if 60 seconds pass and requests are still being processed, IIS gets upset and kills the app pool. This time no application_end would trigger. Similarly, no error event handler would be triggered.

    So, if you want to check the Application Pool recycle log, I suggest you could refer to the following articles to enable Application Pool recycle logging in IIS and find the logs.

    How to enable Application Pool recycle logging.

    Troubleshooting badly behaving IIS application pools

    Best regards,

    Monday, October 15, 2018 6:18 AM