IIS池回收/停止时是否执行类终结器



类终结器是在IIS池回收时执行,还是在池停止期间执行。理论上,这应该类似于Application.Run/Stop,但它是吗?

在同样的情况下,我相信,如果应用程序是NET CORE,并且它在Kestrel或IIS中运行控制台应用程序,则控制台应用程序关闭将运行终结器。还是这样?

若要检测ASP.NET Core中的应用程序关闭,可以在Configure方法中添加一个事件。

下面是strtup类的列表:

1( IApplicationBuilder

2( I托管环境

3( ILoggerFactory

4( I应用程序寿命

public class Startup
{
public void Configure(IApplicationBuilder app, IApplicationLifetime applicationLifetime)
{
applicationLifetime.ApplicationStopping.Register(OnShutdown);
}

private void OnShutdown()
{
//this code is called when the application stops
}
}

https://gist.github.com/davidfowl/4015810

最新更新