Share via

.NET 8.0 MVC APP returns 'Service Unavailable' after a while when deploying to IIS 10, but works well in IDE and Docker Desktop

Kevin Wu 0 Reputation points
2025-05-07T21:35:15.5766667+00:00

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>

  • <EventData>

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

Developer technologies | .NET | .NET Runtime

1 answer

Sort by: Most helpful
  1. Kevin Wu 0 Reputation points
    2025-05-20T15:06:36.33+00:00

    A MS technician helped on this. Some code changes were made, and it appears to be fine now.

    Refer to this: https://techcommunity.microsoft.com/blog/iis-support-blog/asp-net-core-503-server-has-been-shutdown/3830338

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.