zl程序教程

您现在的位置是:首页 >  其它

当前栏目

Hosted Services require keep alive

Services require keep alive
2023-09-11 14:20:28 时间

转自: 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.