我正在网上冲浪,发现文章使用相同网站的cookie属性预防CSRF.
在链接维护上我们需要添加Set-Cookie标头.
Set-Cookie:key = value; 仅Http; SameSite =严格
现在我的问题是,我想在我的ASP.NET站点中设置所有Cookie和身份验证Cookie.我尝试使用IIS中的标头来设置它,但有人说这是错误的实现方式.
我也在下面尝试过.
HttpCookie newAuthenticationCookie = new HttpCookie(FormsAuthentication.FormsCookieName
, FormsAuthentication.Encrypt(newAuthenticationTicket))
{
HttpOnly = true
};
newAuthenticationCookie.Values.Add("SameSite", "strict");
Run Code Online (Sandbox Code Playgroud)
但它似乎没有帮助我.
请建议我更好的方法来做到这一点.
谢谢.