Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS killing ASPNET Core app

I'm hosting an ASPNET Core 1.1 app on IIS with the following settings to keep it always running

enter image description here

However, I see the app getting terminated time to time. Before termination I see the following in the logs

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.

The POST /iisintegration looks interesting. Is IIS sending a command to terminate the app?

P.S.

After digging around IIS integration middleware, it looks like that POST is actually IIS sending a termination command. This is the code that handles it

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;
}

So my question is: Is there a way to disable this functionality?

like image 774
ubi Avatar asked Mar 16 '18 02:03

ubi


People also ask

Does IIS support .NET Core?

The module allows ASP.NET Core apps to run behind IIS. If the Hosting Bundle is installed before IIS, the bundle installation must be repaired. Run the Hosting Bundle installer again after installing IIS.

Can ASP.NET Core run without IIS?

An ASP.NET Core app can be hosted on Windows as a Windows Service without using IIS. When hosted as a Windows Service, the app automatically starts after server reboots.

Does .NET Core still use web config?

ASP.NET Core no longer uses the Global. asax and web. config files that previous versions of ASP.NET utilized.


1 Answers

Try to remove your Recycling Conditions from your application pool

like image 128
Mossila Avatar answered Oct 09 '22 11:10

Mossila