Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Core 3 - IIS - Application Initialization doesn't work

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?

like image 233
Coruscate5 Avatar asked Jan 25 '20 00:01

Coruscate5


People also ask

How do I deploy a .NET core application in IIS?

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.

What is enable preload in IIS?

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".

What is application initialization in IIS?

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.


1 Answers

For the Set "Preload" to true on the Web Site to work you need also to activate anonymous authentication on the web site

like image 51
Spirit_Life Avatar answered Oct 06 '22 23:10

Spirit_Life