To be able to shutdown background process (implemented with Quartz.Net) I need to detect web application shutdown in AspNet5 beta8. In previous versions of Asp.Net it was possible to execute code on Application_End. What is the equivalent of Application_End event in AspNet5?
So far I tried IApplicatonLifetime in Configure, but it does not fire when I stop the web application:
public void Configure(IApplicationBuilder app, IApplicationLifetime lifetime)
{
lifetime.ApplicationStopping.Register(() =>
{
Logger.LogInformation("Application Stopping. Do stuff.");
});
lifetime.ApplicationStopped.Register(() =>
{
Logger.LogInformation("Application Stopped. Do stuff.");
});
}
I don't get any response on both ApplicationStopping and ApplicationStopped.