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
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.
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.
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()