Automatically Validate Antiforgery Tokens in ASP.NET Core MVC
Protect your POST endpoints from Cross-Site Resource Forgery (CSRF)
Manually add the [ValidateAntiForgeryToken] attribute to all POST endpoints to protect against CSRF
Or you can simply
builder.Services.AddControllersWithViews(options =>
{
options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute()); // CSRF protection
});
Done. No need to remember to decorate all your POST action methods with the attribute.