Reputation: 263
I am using .net core 3.1 on my project. I set Secure flag true for every cookie but I can not set Secure flag for AspNetCore.Antiforgery.
services.AddControllers(options =>
{
options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
});
Upvotes: 17
Views: 10155
Reputation: 7190
You can set secure flag for AspNetCore.Antiforgery
like following:
services.AddAntiforgery(options =>
{
options.Cookie.SecurePolicy =CookieSecurePolicy.Always;
});
Remember to clear the previous cookies first.
Upvotes: 40