What is a .AspNetCore.Antiforgery.xxxxxxx cookie in .Net Core?

I tried to use the ValidateAntiForgeryToken in .Net Core, but I was getting a .AspNetCore.Antiforgery.xxxxxxx cookie.

What is a .AspNetCore.Antiforgery.xxxxxxx cookie?

+4
source share
1 answer

ASP.NET Core searches this cookie to find the X-CSRF token.

ValidateAntiForgeryToken is an action filter in which requests made with actions that apply this filter will be blocked if the request does not contain a valid antiforgery token.

Typically, ASP.NET Core can look for a token in a cookie or header. So you may have a situation where

  • cookie
  • cookie , ASP.NET.

​​ASP.NET cookie, DefaultCookiePrefix ( ".AspNetCore.Antiforgery." ).

, antiforgery CookieName:

services.AddAntiforgery(options => options.CookieName = "X-CSRF-TOKEN-COOKIENAME");

, :

services.AddAntiforgery(options => options.HeaderName = "X-XSRF-TOKEN");

:

+3

Source: https://habr.com/ru/post/1685638/


All Articles