Is it possible to detect when a Razor 2 Web Pages application (asp.net) is being unloaded - for example, as a result of IIS/WebMatrix being stopped?
There is _AppStart.csthml to handle the application start.
Is there something similar for "application stop"?
EDIT:
Low reputation, cannot vote up/answer myself yet.
I have added Global.asax and indeed there is Application_End event for handling app shutdown.
Can I use that instead, or your method is preferred?
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}