Skip to content

Explicitly calling app.UseRouting() in Blazor Web App results in exception that antiforgery middleware is missing #49654

@danroth27

Description

@danroth27

If I add an explicit call to app.UseRouting() in a Blazor Web App, I get the following exception:

"Endpoint / (/) contains anti-forgery metadata, but a middleware was not found that supports anti-forgery."

Repro steps:

  • Create a Blazor Web App
  • Update Program.cs to call app.UseRouting() explicitly:
app.UseRouting();
app.MapRazorComponents<App>();
  • Run the app

Expected result: App runs without error
Actual result: Exception saying that the antiforgery middleware is required
Workaround: Adding the antiforgery middleware resolves the issue

.NET SDK version: 8.0.100-preview.7.23375.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions