小编roh*_*ena的帖子

如何在 ASP.NET 4.6.1 及以下版本中支持 SameSite Cookie

我使用 asp.net MVC 开发了一个网站

我们确实对站点进行了扫描,它给出了一个 CSRF,要求将站点 cookie 设置为同一站点。在 web.config 中尝试了下面的代码,但似乎它只能从 4.7.1 开始工作 -

我们有什么办法可以在 .Net 4.6 中实现这一点,非常需要帮助:)

  1. cookie 同一站点=“无”
<httpCookies cookieSameSite="None" />
Run Code Online (Sandbox Code Playgroud)
  1. 重写规则
<rewrite>
      <outboundRules>
        <rule name="Add SameSite" preCondition="No SameSite">
          <match serverVariable="RESPONSE_Set_Cookie" pattern=".*" negate="false" />
          <action type="Rewrite" value="{R:0}; SameSite=strict" />
          <conditions>
          </conditions>
        </rule>
        <preConditions>
          <preCondition name="No SameSite">
            <add input="{RESPONSE_Set_Cookie}" pattern="." />
            <add input="{RESPONSE_Set_Cookie}" pattern="; SameSite=strict" negate="true" />
          </preCondition>
        </preConditions>
      </outboundRules>
    </rewrite>
Run Code Online (Sandbox Code Playgroud)

cookies .net-4.6 .net-4.6.1 samesite

5
推荐指数
0
解决办法
3120
查看次数

标签 统计

.net-4.6 ×1

.net-4.6.1 ×1

cookies ×1

samesite ×1