How to tell why an IIS application pool is recycled

后端 未结 4 1245
走了就别回头了
走了就别回头了 2020-12-25 14:31

Background:

I\'ve deployed an ASP.NET MVC 3 app that works on my machine to a shared hosting provider and am discovering some problems that appear to be related to

4条回答
  •  执念已碎
    2020-12-25 15:08

    Research - 1

    Firstly I tried using System.Web.ProcessModelInfo.GetCurrentProcessInfo() and System.Web.ProcessModelInfo.GetHistory(int). The results of these methods return info such as the PID, start time, age, status, and peak memory usage. Unfortunately these were unavailable in my hosting environment:

    HttpException 0x80004005 - Process metrics are available only when the ASP.NET process model is enabled. When running on versions of IIS 6 or newer in worker process isolation mode, this feature is not supported.

    This approach might work for others though, so if you're in this situation, give it a shot.

    Research - 2

    The property System.Web.Hosting.HostingEnvironment.ShutdownReason is an enum with lots of values, but unfortunately all the cases I outline in my question are bundled into a single enum value:

    ApplicationShutdownReason.HostingEnvironment: The hosting environment shut down the application domain.

    Research - 3

    ScottGu has an approach on his blog (which is the same code Kev posted) that uses reflection to access internal state of the HttpApplication. Unfortunately in this case it only reports the same detail as #2 above:

    _shutDownMessage =
      HostingEnvironment initiated shutdown
      HostingEnvironment caused shutdown
    
    _shutDownStack =
      at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
      at System.Environment.get_StackTrace()
      at System.Web.Hosting.HostingEnvironment.InitiateShutdownInternal()
      at System.Web.Hosting.HostingEnvironment.InitiateShutdownWithoutDemand()
      at System.Web.Hosting.PipelineRuntime.StopProcessing()
    

提交回复
热议问题