This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Description
Possibly related to #151.
In the following code:
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.Framework.DependencyInjection;
using System;
namespace TestAppShutdownWebApi
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IApplicationLifetime lifetime)
{
lifetime.ApplicationStopping.Register(OnStopping);
app.UseMvc();
}
public void OnStopping()
{
Console.WriteLine("OnStopping");
}
}
}
...the OnStopping event is not raised.
The following code works.
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http;
using Microsoft.Framework.DependencyInjection;
using System;
namespace TestAppShutdownWebApi
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
}
public void Configure(IApplicationBuilder app, IApplicationLifetime lifetime)
{
lifetime.ApplicationStopping.Register(OnStopping);
}
public void OnStopping()
{
Console.WriteLine("OnStopping");
}
}
}
This is the case for Microsoft.AspNet.Server.WebListener or Kestrel.