I am developing an ASP.NET Core 3.1 application. I am not using any kind of authentication, session data/logic and form elements. I see the .AspNetCore.Antiforgery cookie in my in my developer console, although I did not call services.AddAntiforgery()
in my Startup
class.
I found this StackOverflow question with a very unsatisfying accepted answer, since this cookie will still be sent to the client (pointed out by hemp's comment).
So my question is: How do I completely remove this CSFR cookie?
<form method="post" asp-antiforgery="false">
– KuchenAutoValidateAntiforgeryTokenAttribute
which will require an anti forgery token only for unsafe requests. As long as the connection is secure your site wil not pass a token forGET,HEAD,OPTIONS,TRACE
requests learn.microsoft.com/en-us/dotnet/api/…. Generally I would not omit theAnti Forgery
but if you must at least have a small backup. – Kuchen