This issue drives me crazy.
I have a web app designed on .NET 8.0, MVC, and use OpenID to connect to AAD for authentication. It works well in IDE (VS 2022). The docker image also runs fine on Docker Desktop. Unfortunately, after deployed to IIS 10 on Windows server 2022, after certain number of visits, it returns 'service unavailable'. I have to stop the pool or the site, and restart it, and then it is back to work. Even if I took out all the app logic, the EE framework part, the auth part, etc., it behaves the same.
What I have tried:
Change IIS settings including:
.Net CLR version (2.0/4.0/unmanaged)
Enable 32-bit app (true/false)
Queue Length (1000/10000)
Start Mode: Always Runnings
Idle timeout: 0
Load User Profile: True
Max worker processes (1/10/20)
Disable Overlapped Recycle: True
Virtual mem: 0
Change Site Preload Enabled: true
All these changes DO NOT make a difference. What is worse, there is very little logs to diagnose. All I got (I believe this is related) is such an entry in Windows logs -> Application:
Warning 5/7/2025 3:26:27 PM IIS AspNetCore Module V2 1005 None
Failed to gracefully shutdown application 'MACHINE/WEBROOT/APPHOST/DEFAULT WEB SITE/mysite'.
<Provider Name="IIS AspNetCore Module V2" />
<EventID Qualifiers="0">1005</EventID>
<Version>0</Version>
<Level>3</Level>
<Task>0</Task>
<Opcode>0</Opcode>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2025-05-07T20:26:27.6993116Z" />
<EventRecordID>42287</EventRecordID>
<Correlation />
<Execution ProcessID="0" ThreadID="0" />
<Channel>Application</Channel>
<Computer>MyserverName</Computer>
<Security />
</System>
<Data>Failed to gracefully shutdown application 'MACHINE/WEBROOT/APPHOST/DEFAULT WEB SITE/MySite'.</Data>
<Data>Process Id: 11100.</Data>
<Data>File Version: 18.0.24262.10. Description: IIS ASP.NET Core Module V2 Request Handler. Commit:</Data>
</EventData>
</Event>