c# - What is .AspNetCore.Antiforgery.xxxxxxx cookie in .Net Core? -
i trying use validateantiforgerytoken in .net core getting .aspnetcore.antiforgery.xxxxxxx cookie missing.
what .aspnetcore.antiforgery.xxxxxxx cookie?
asp.net core looks cookie find x-csrf token.
the
validateantiforgerytoken
action filter requests made actions have filter applied blocked unless request includes valid antiforgery token.
in general asp.net core may token in cookie or header. may have situation when
- instead of cookie header used pass token
- cookie token has different name asp.net core expected.
by default, asp.net core generate , expect unique cookie name beginning defaultcookieprefix (".aspnetcore.antiforgery.").
this overriden using antiforgery option cookiename
:
services.addantiforgery(options => options.cookiename = "x-csrf-token-cookiename");
if talking header, name specified by:
services.addantiforgery(options => options.headername = "x-xsrf-token");
look into:
- preventing cross-site request forgery (xsrf/csrf) attacks in asp.net core
- readme in antiforgery repo contains links samples
- so: using antiforgery cookie in asp.net core non-default cookiename
Comments
Post a Comment