Search code examples
c#.net-coreasp.net-core-mvcasp.net-core-hosted-services

ASP.NET Core - server stopping and starting on demand


I had a strange experience running ASP.NET Core web application. Our company has two dotnetcore web applications. Currently both web app is rarely used. IHostedService is also used for both: https://www.stevejgordon.co.uk/asp-net-core-2-ihostedservice

Both web application is stopped running at some point and when the user visits the page via web browser everything is back to normal. The user is not experiencing any error. Does anyone know why it is stopping and starting? Probably the web app is in idle status and that's why it is not running. Any documentation would be useful.


Solution

  • My teammate figured out what was the problem. You need to change the app pool on IIS, here are the steps:

    Web server >> IIS Manager >> Application Pools >> PROS >> Advanced Settings... >> Process Model >> Idle Time-out (minutes): 0

    We also set the recycle value to zero.

    EDIT You can find more details here on this question: IHostedService Stop without any reason