I've updated my blazor server app to the new .NET 6.0 and I'm using the latest Radzen.Blazor library version 4.2.2. I have a page where I'm using the RadzenUpload component, all the code used to work properly but now I'm getting this error:
Antiforgery token validation failed. "The required antiforgery request token was not provided in either form field \"__RequestVerificationToken\" or header value \"RequestVerificationToken\"."
Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The required antiforgery request token was not provided in either form field "__RequestVerificationToken" or header value "RequestVerificationToken". at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.ValidateRequestAsync(HttpContext httpContext) at Microsoft.AspNetCore.Mvc.ViewFeatures.Filters.ValidateAntiforgeryTokenAuthorizationFilter.OnAuthorizationAsync(AuthorizationFilterContext context)
I've tried a few different approaches in an attempt to disable the validation of the token or settting it using:
<RadzenUploadHeader Name="RequestVerificationToken" Value="@token" />
I also tried disabling the validation globally using:
services.AddMvc().AddRazorPagesOptions(options =>
{
options.Conventions.ConfigureFilter(new IgnoreAntiforgeryTokenAttribute());
});
Or on the mvc controller method that handles the file upload, using the attribute:
IgnoreAntiforgeryToken(Order = 1001)
This one also does not work:
services.AddAntiforgery(options => { options.SuppressXFrameOptionsHeader = true; });
None of the options worked.
Any ideias?
Thanks