Skip to content

AntiForgeryToken validation fail when open an asp.net core url from an angular application #3768

@ioantoader

Description

@ioantoader

I have an asp.core mvc aplication which is the identity server application (IdentityServer4 + ASP.Net core Identity). In my angular client which use this asp.core app to get the bearer token i call like: <a mat-menu-item [href]="/Manage/Index" target="_blank" rel="noreferrer noopener" referrerpolicy="no-referrer"> the Index page from ManageControler. When I open this url in two tabs and edit some values and press submit, in one is working and in one I got
2018-10-30 08:18:34.792 +00:00 [Information] Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ValidateAntiforgeryTokenAuthorizationFilter: Antiforgery token validation failed. The antiforgery cookie token and request token do not match.
Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The antiforgery cookie token and request token do not match.
at Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery.ValidateTokens(HttpContext httpContext, AntiforgeryTokenSet antiforgeryTokenSet)
at Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery.ValidateRequestAsync(HttpContext httpContext)
at Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ValidateAntiforgeryTokenAuthorizationFilter.OnAuthorizationAsync(AuthorizationFilterContext context)

If I enter the same url manual in two tabs is function without any problems.

Any Idea?
Thanks
Ioan Toader

Metadata

Metadata

Assignees

Labels

area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions