I've been following the IHostedService documentation in order to run a background task using the .NET Core MVC framework.
I would like the service to start automatically in IIS, however, it doesn't work.
I have done the following:
- Installed Application Initialization feature on the Windows Server
- Set "Preload" to true on the Web Site
- On the AppPool, set "AlwaysRunning"
- On the AppPool, set "Idle Timeout" to 0
- On the AppPool, ensured it was running under "No Managed Code"
- In the ApplicationInitialization configuration, set the following flags:
- doAppInitAfterRestart = True
- skipManagedModules = False
- Added an initializationPage key, = "/start" (a blank MVC call just to start the app)
Oddly, these steps work on fresh Windows Server installation, but not on the server I want to use.
On the problematic server, I can see the w3wp process try to start the dotnet process (via Procmon), but it doesn't actually run any dotnet core code until I send a real HTTP request from a browser.
I have read many GitHub threads that say this should work regardless of the exact IIS version - what else could be going on?