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:
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?
Create the IIS site. On the hosting system, create a folder to contain the app's published folders and files. In a following step, the folder's path is provided to IIS as the physical path to the app. For more information on an app's deployment folder and file layout, see ASP.NET Core directory structure.
Setting preloadEnabled to "true" tells IIS 8.0 that it sends a "fake" request to the application when the associated application pool starts up. That is why in the previous step we set the application pool's startMode to "AlwaysRunning".
IIS Application Initialization allows website administrators to configure a web application to be pre-loaded as soon as the worker process starts, before the first request arrives. By pre-loading the application, the worker process is able to reduce the time it takes to respond to the first request.
For the Set "Preload" to true on the Web Site to work you need also to activate anonymous authentication on the web site
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With