Keep .NET 5 Web API running all the time in IIS - asp.net-core

I have .Net 5 Web API hosted on IIS 10.
I configured IIS Application pool and IIS Site as mentioned here.
Install server feature - Application Initialization Module
Set the Start Mode to AlwaysRunning
Set Preload Enabled to True
Set the Idle Time-out (minutes) to 0 (zero)
The problem is - When I reset IIS(iisreset), app is not initializing. I see only app is shutdown in logs.
2021-10-26 16:35:16.5366|INFO|Microsoft.Hosting.Lifetime|Application is shutting down...
2021-10-26 16:35:16.5366|INFO|Quartz.Core.QuartzScheduler|Scheduler QuartzScheduler_$_NON_CLUSTERED shutting down.
What am I missing?

Finally I figured out that for "Preload" = true on the Web Site to work you should activate anonymous authentication on the web site.
If anyone knows how to fix this for Windows Authentication only, please add your answer.

Related

IIS, application pool stop Automatically

I am running WCF services on IIS 7.5 with .NET framework version 4.5 and it is in integrated mode. Whenever I deploy new code on IIS, it causes application pool to crash resulting in 503 error. I tried to dig into code but I am not able to figure out the root cause of the problem because of the large code base. I have ensured that it is not because of any server or IIS setting (as reverting the build makes IIS normal). I have also looked into event logs but not able to find anything, I am already logging application error but nothing is helping. Is there anyway I can trap the event or error just before crashing pool as I am running it integrated mode? Any help will be appreciated.

.NET Core Web App Restarting

I have a .NET core web app (console) hosted in IIS on a Windows machine. In the ConfigureServices method in Startup.cs I have a line of code which sends me an email so that I know when the service is restarted. When a new release is being deployed, I get that email, understandably. But I also receive that email at random times when there was no apparent restart of the machine, the app, or of any IIS component. Would there be any other thing which would cause it to restart? I'm not sure why this is happening.
Thanks,
IIS has a lot of settings for AppPool reset, like e.g. at given time, etc. You can check the advanced settings of your application pool that is set up to run your program and see if there is anything suspicious. It might be some inactivity timeout e.g.

why dotnet.exe is terminated under IIS

Introduction
I do have WebApi on.Net Core 1.1 & simple test application executing some scenario with calls to my API in multiple threads. Web API is hosted under IIS on WS 2012 R2.
Problem
When I do start my test application with 20 threads in 20-30s test application begin to receive 401 error from the server. After some investigation, I've noticed that dotnet.exe process is suddenly terminated & restarted on the server on high load.
There is no information neither in my logs nor in Windows event log (only one from IIS AspNetCore Module about starting new process: Application 'MACHINE/WEBROOT/APPHOST/DEFAULT WEB SITE' started process '10248' successfully and is listening on port '23570')
I've tried to reproduce this on my machine without any success - this does not happen when my API is hosted in IIS Express from VS.
Question
What may be the reason?

ASPX.NET Core - random 502 error on IIS server

We just launched a site that runs on ASP.NET Core 1.1, Windows 2008R2, IIS 7.5 with all the latest patches to 2008 and asp.net.
The site runs fine, but goes down with no apparent pattern. All of a sudden it would start returning 502 response:
502 – Web server received an invalid response while acting as a gateway or proxy server
Restarting the site in IIS, or recycling site’s application pool brings the site up, but the problem reoccurs within a few hours. As workaround, we configured IIS to recycle app pool every 90 minutes, and that seemed to keep the site up all of the time.
Any recommendations on how to troubleshoot this problem?
Thank you!
IIS says with this 502 error that Kestrel (behind it) returned something "wrong". Enable (more) logging, and inspect logs before first 502 response. Some previous request "breaks" your app.

Restart a WCF service after a server reboot

Is there some mechanism in WCF that can be used to "pre-start / warm-up" WCF services that are hosted in IIS ?
- something like the warm-up scripts for SharePoint sites
I have the situation where servers are re-booted over night and next day there is a long delay while the WCF services spin-up. I can't change the time-out in various applications that use the services, so the first users are reporting errors in the morning when they go to use their applications
This is on Windows 2003 Server and IIS 6.0, so the IIS Application Pool Warm-Up Module, http://www.iis.net/download/applicationwarmup, as that's for IIS 7.5
NOTE: the module seems to have been temporarily withdrawn, see details on ... IIS Forum
I know you will don't like the answer and I think I repeat myself because it is not the first time I'm posting it. The way to warm-up anything in IIS prior to version 7.5 is using scheduled console application to ping your web site / services and warm them up. It is ugly solution but it works, it is easy and I saw it on every project which had to deal with this requirement.
WCF services should be instantly ready when they start. Just make sure the services are set to automatically start when the server boots.
You can use Windows Server AppFabric, it has Auto Stat feature to keep the service always on. But you need to be on IIS 7.5 to install App Fabric.