IIS杀死ASPNET核心应用程序

时间:2018-03-16 02:31:38

标签: c# asp.net .net asp.net-core iis-8

我在IIS上使用以下设置托管ASPNET Core 1.1应用程序以使其始终运行

enter image description here

但是,我看到应用程序不时被终止。在终止之前,我在日志中看到以下内容

2018-03-14 17:20:53.202 [Information] Request starting HTTP/1.1 POST http://127.0.0.1:32751/myapp/iisintegration  0
2018-03-14 17:20:53.205 [Information] Request finished in 3.98ms 202 
2018-03-14 17:20:53.203 [Error] Unhandled exception
System.Threading.Tasks.TaskCanceledException: A task was canceled.

POST /iisintegration看起来很有趣。 IIS是否发送命令来终止应用程序?

P.S。

在挖掘IIS integration middleware之后,看起来POST实际上是IIS发送终止命令。这是处理它的代码

private static readonly PathString ANCMRequestPath = new PathString("/iisintegration");
...
    // Handle shutdown from ANCM
if (HttpMethods.IsPost(httpContext.Request.Method) &&
    httpContext.Request.Path.Equals(ANCMRequestPath) &&
    string.Equals(ANCMShutdownEventHeaderValue, httpContext.Request.Headers[MSAspNetCoreEvent], StringComparison.OrdinalIgnoreCase))
{
    // Execute shutdown task on background thread without waiting for completion
    var shutdownTask = Task.Run(() => _applicationLifetime.StopApplication());
    httpContext.Response.StatusCode = StatusCodes.Status202Accepted;
    return;
}

所以我的问题是:有没有办法禁用此功能?

1 个答案:

答案 0 :(得分:1)

尝试从应用程序池中删除Recycling Conditions