Controlling IHostedService execution order in ASP.NET Core 3.x

added by DotNetKicks
8/18/2020 10:29:19 AM

491 Views

ASP.NET Core 3.0 re-platformed the WebHostBuilder on top of the generic IHost abstraction, so that Kestrel runs in an IHostedService. Any IHostedService implementations you add to Startup.ConfigureServices() are started before the GenericWebHostService that runs Kestrel. But what if you need to start your IHostedService after the middleware pipeline has been created, and your application is handling requests?


0 comments