Skip to content

EditForm and Antiforgery for Blazor Web Assembly #19687

@boukenka

Description

@boukenka

Hello,

I am trying to add antiforgery protection to the EditForm for login and registration.

I have added the [AutoValidateAntiforgeryToken] attribute for the controller
and the following coding at startup for the server part:

services.AddMvc(options =>
{
     options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
});

The server response is 400 Bad request when a log in operation is submitted.
How to resolve it? Is there an anti-forgery mechanism in EditForm? Or with the addition of @Html.AntiForgeryToken()?

Further technical details

ASP.NET Core version 3.1.2
Blazor WebAssembly 3.2.0 Preview 1
Microsoft Edge 82.0.439.1
It's a Blazor Web Assembly with ASP.NET core hosted
Visual Studio 16.5.0 Preview 5.0

Metadata

Metadata

Assignees

Labels

area-blazorIncludes: Blazor, Razor Componentsfeature-blazor-wasmThis issue is related to and / or impacts Blazor WebAssembly

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions