dotnet / dotnet/aspnetcore

Bad Request - Request Too Long - IIS Server

Open
#57,545 20 comments 1 reaction 0 assignees View on GitHub
area-auth area-networking Docs
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

I cloned the repository and started working with the [BlazorWebappOidc](https://github.com/dotnet/blazor-samples/tree/main/8.0/BlazorWebAppOidc) project. I configured the Entra ID settings, such as the client ID and tenant ID, using the details from my Entra ID tenant account. After running the application locally on the Kestrel server with the HTTPS profile, the Blazor application launched successfully. The interface loaded in the browser, and I was able to log in using my Entra ID account. After a successful callback to my Blazor application URL, I was redirected and received the expected details (Such as Username, email address, etc).

However, when I deployed the same application on an IIS server, I encountered an issue. While the Blazor application opened, when I attempted to log in to my Microsoft Entra ID account, I received a Bad Request - Request Too Long (HTTP Error 400. The size of the request headers is too long) error after the callback.

### Expected Behavior

After a successful callback to my Blazor application URL, I was redirected and received the expected details (Such as Username, email address, etc).

### Steps To Reproduce

- Go to repository and clone [BlazorWebappOidc](https://github.com/dotnet/blazor-samples/tree/main/8.0/BlazorWebAppOidc) and Open the application in Visual Studio.

- Provide the needed configuration like Tenant ID, Client ID, etc for your Microsoft Azure Entra ID.

- 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" } } }`

- Click on login and it will redirect you to the authentication flow then provide the Credentials for login (Entra ID Username and password).

- After the successful callback you get back to the Blazor Application and then you will see the Error

Bad Request - Request Too Long (HTTP Error 400. The size of the request headers is too long.)

### Exceptions (if any)

_No response_

### .NET Version

DOTNET 8

### Anything else?

![Screenshot_10](https://github.com/user-attachments/assets/5ea76b6e-b850-417e-a832-dcb6fd91652b)

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

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.