Hosted Services require keep alive

转自: https://stackoverflow.com/questions/53753802/do-recurring-hosted-services-require-keep-alive

 

If you run your ASP.NET Core application in IIS (not IIS Express):

  • For your hosted service to start automatically, you need to set the Start Mode of the application pool to Always Running. See Rick Strahl for more information.
  • For your hosted service to keep running indefinitely, you need to set the Idle Time-out of the application pool to 0.

If you run the application as a Windows Service, none of this is needed.

Also, for forward compatibility, make your hosted service inherit the BackgroundService class and register it for dependency injection using AddHostedService.

AFAIK, using the IIS in-process hosting model in .NET Core 2.2 has no effect on this.

posted @ 2020-04-21 11:17  小小高  阅读(168)  评论(0编辑  收藏  举报