2

I have ASP MVC application. In Global.aspx I have Application_Start() and Application_End(object sender, EventArgs e).

I am aware that Application_End can triggered when web.config changes, site stopped/restarted etc. But I want to log what exactly triggered Application_End. sender holds the details but I am unable to find to which class I should typecast it.

Priyesh Kumar
  • 2,837
  • 1
  • 15
  • 29
  • 2
    This could be a duplicate of question: https://stackoverflow.com/questions/14855938/how-do-i-programmatically-find-why-application-end-is-invoked – TimAlonso Apr 10 '19 at 07:13
  • Thanks @TimAlonso, ApplicationShutdownReason is providing the required information. Is there any doc that describe how to use `sender` and `eventargs` in app lifecycle? – Priyesh Kumar Apr 10 '19 at 09:17
  • I'd suggest having a look at HttpApplication's methods and events. This is where Application_End(object sender, EventArgs e) is inherited from: https://learn.microsoft.com/en-us/dotnet/api/system.web.httpapplication?view=netframework-4.7.2 – TimAlonso Apr 10 '19 at 09:46

0 Answers0