In my ASP.NET application that I deploy on Windows Azure I want to log as many useful data as possible. There’s Application_End() method:
protected void Application_End(object sender, EventArgs e)
{
}
which is invoked with sender being System.Web.HttpApplicationFactory and e being just System.EventArgs. With such parameters all I can do is just log their types which isn’t very useful.
Can I obtain any useful data from these parameters? Are there cases when Application_End() is invoked with parameters that have other – more useful – actual types?
IIS,
class HttpRuntimeincluded, sources can be downloaded. Careful analysis shows that indeed the event parameters are always the same and convey no useful information. The call stack for the event is also useless – it is alwaysbut… There is
System.Web.Hosting.HostingEnvironment.ShutdownReasonthat can be retrieved from withinApplication_End()and that is set byHttpRuntimewhen the application shutdown is being initiated.So the “interesting data” is
System.Web.Hosting.HostingEnvironment.ShutdownReason.Also see this closely related question