相关疑难解决方法(0)

使用相同站点cookie属性防止CSRF

我正在网上冲浪,发现文章使用相同网站的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)

但它似乎没有帮助我.

请建议我更好的方法来做到这一点.

谢谢.

asp.net iis cookies csrf

24
推荐指数
6
解决办法
2万
查看次数

标签 统计

asp.net ×1

cookies ×1

csrf ×1

iis ×1