我在网上冲浪,发现了第Preventing CSRF with the same-site cookie attribute条.
作为链接维护,我们需要添加设置Cookie头.
Set-Cookie:Key=Value;HttpOnly;SameSite=Strict
现在我的问题是,我想在我的ASP.NET站点的"所有Cookie"和"身份验证Cookie"中设置它. 我试图使用来自IIS的头来设置它,但是有人说这是错误的实现方式.
我也试过下面的方法.
HttpCookie newAuthenticationCookie = new HttpCookie(FormsAuthentication.FormsCookieName
, FormsAuthentication.Encrypt(newAuthenticationTicket))
{
HttpOnly = true
};
newAuthenticationCookie.Values.Add("SameSite", "strict");
但这似乎帮不了我.
请给我一个更好的方法.
谢谢