dotnet / dotnet/aspnetcore

HTTP 400 for negotiate call in Blazor Web App (InteractiveServerSideRendering(prerendering:false)

Open
#64,713 1 comment 2 reactions 0 assignees View on GitHub
area-blazor investigate
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 9h
Merged PRs (30d)
276

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

Using the Blazor Web App template I changed two things:
- disable prerendering
- configure app to run from subfolder `subfolder`

I'm running it on the dev machine -> Environment is Development

After these changes the call to http://localhost:5187/subfolder/_blazor/negotiate?negotiateVersion=1 returns a HTTP 400 with the message `A valid antiforgery token was not provided with the request. Add an antiforgery token, or disable antiforgery validation for this endpoint.` and the screen remains blank.

### Expected Behavior

work as normal but serving from configured subfolder

### Steps To Reproduce

Minimal repro based on empty template. Steps as individual commits can be found in the github repo https://github.com/philippdolder/negotiate-400

It's based on `dotnet new blazor -o Ui --interactivity Server --empty --all-interactive --use-program-main`

### Exceptions (if any)

_No response_

### .NET Version

10.0.100

### Anything else?

output of `dotnet --info`

.NET SDK:
Version: 10.0.100
Commit: b0f34d51fc
Workload version: 10.0.100-manifests.4c0ca8ba
MSBuild version: 18.0.2+b0f34d51f

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26200
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.100\

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
Version: 10.0.0
Architecture: x64
Commit: b0f34d51fc

.NET SDKs installed:
8.0.319 [C:\Program Files\dotnet\sdk]
8.0.416 [C:\Program Files\dotnet\sdk]
9.0.308 [C:\Program Files\dotnet\sdk]
10.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
DOTNET_CLI_TELEMETRY_OPTOUT [1]
DOTNET_WATCH_RESTART_ON_RUDE_EDIT [1]

Contributor guide

Open the contributing guide

Research direction

Start by cloning the linked minimal repro and running the Blazor Web App template with prerendering disabled and the app configured under the `subfolder` path. Reproduce the `_blazor/negotiate` request and inspect the antiforgery response. Done means the negotiate call succeeds and the page renders normally when hosted from the configured subfolder.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.