dotnet / dotnet/aspnetcore

Blazor Web App - IIS - App shutdown on refresh - HTTP Error 503.0 - Server has been shutdown

Open
#57,707 10 comments 0 reactions 0 assignees View on GitHub
area-networking feature-iis
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

I'm using the .NET 8 Blazor web app template, which includes both a client and server project. In the server project, I have an API controller that I call using HttpClient. When running the application on Kestrel (using commands like dotnet run or dotnet projectassembly.dll), everything works as expected. However, when I deploy the application to either a local or remote IIS, or run it via Visual Studio on IIS, the site starts but fails after requesting the Web API controllers. It returns a 503 error for all requests, and the application becomes unresponsive with no indication of what went wrong.

### Expected Behavior

The application should work smoothly and get data from database on API calls and don't shut down on refresh or Api calling.

### Steps To Reproduce

Steps to reproduce the behavior:

1. Go to repository and clone [BlazorWebappOidc](https://github.com/dotnet/blazor-samples/tree/main/8.0/BlazorWebAppOidc) and Open the application in Visual Studio.
2. Add an IIS Settings to launchsettings.json to run the application on IIS locally then Run
` "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "http://localhost:46294", "sslPort": 44381 } },"profiles": { "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } }`
3. Add an API controller to server project and add a couple of method to get data from database.
4. Register HTTPClient at client side project to call the API.
5. lets run the project on the IIS profile and try to fetch data via method we have added into API controller this will return response Error 503 Shut down or just refresh the page it will show the error.

### Exceptions (if any)

_No response_

### .NET Version

DOTNET 8

### Anything else?

**For reference What I am getting on the browser please see the images.**

![Screenshot_15](https://github.com/user-attachments/assets/96237780-0886-49e9-9f00-22d316e48f13)
![Screenshot_16](https://github.com/user-attachments/assets/771f55ce-346d-4ad1-860f-8a076c948ead)

cc: @guardrex https://github.com/dotnet/blazor-samples/issues/348

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.