I was trying to use ValidateAntiForgeryToken in .Net Core but I was getting .AspNetCore.Antiforgery.xxxxxxx cookie is missing.
What is this .AspNetCore.Antiforgery.xxxxxxx cookie?
I was trying to use ValidateAntiForgeryToken in .Net Core but I was getting .AspNetCore.Antiforgery.xxxxxxx cookie is missing.
What is this .AspNetCore.Antiforgery.xxxxxxx cookie?
Copyright © 2021 Jogjafile Inc.
ASP.NET Core looks for this cookie to find the X-CSRF token.
In general ASP.NET Core may look for the token in cookie or header. So you may have the situation when
By default, the ASP.NET Core will generate and expect a unique cookie name beginning with the DefaultCookiePrefix (".AspNetCore.Antiforgery.").
This could be overriden using an antiforgery option
CookieName
:For .Net Core 2.0.0 or greater there will be changes:
Reference: https://learn.microsoft.com/en-us/dotnet/api/Microsoft.AspNetCore.Antiforgery.AntiforgeryOptions?view=aspnetcore-2.0
For that use following:
If talking about header, name could be specified by:
Look into: