iis - SameSite cookies IIS

标签 iis

我在 IIS 中尝试过 Samesite cookie。但没有运气。我怎样才能在 IIS 中使用它?顺便说一句,我使用的是 Windows Server 2012 R2。

配置:

<sessionState timeout="60" cookieSameSite="None" />
<httpCookies sameSite="None"/>

最佳答案

这通常在应用程序的启动和初始化中进行管理。

在 IIS(而不是您的应用程序)中执行此操作的一种方法是添加出站重写规则,以将 SameSite=None 附加到响应中发送的 cookie。

示例Web.config:

<system.webServer>
  <rewrite>
    <outboundRules>
      <clear />
      <rule name="Add SameSite" preCondition="No SameSite">
        <match serverVariable="RESPONSE_Set_Cookie" pattern=".*" negate="false" />
        <action type="Rewrite" value="{R:0}; SameSite=None" />
      </rule>
      <preConditions>
        <preCondition name="No SameSite">
          <add input="{RESPONSE_Set_Cookie}" pattern="." />
          <add input="{RESPONSE_Set_Cookie}" pattern="; SameSite=None" negate="true" />
        </preCondition>
      </preConditions>
    </outboundRules>
  </rewrite>
</system.webServer>

关于iis - SameSite cookies IIS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59858471/

相关文章:

wcf - IIS 托管的 WCF 休息服务出现 400 错误,URL 是否太长?

c# - 在 ASP.NET 页面的代码隐藏类中响应 IIS 的标准 404 Not Found 页面

c# - 无法让 Fiddler 捕获到 IIS 的本地流量

css - ASP.NET 应用程序 - 在用户登录到站点之前不加载 Webfonts

iis - asp - 浏览器下载文件而不是显示

iis - 使用 IIS 负载平衡 Tomcat 服务器

.net - IIS7.5 上托管的 WCF netTcpBinding 停止工作

asp.net - 如何关闭 IIS 中的预编译?

ssl - IIS 7.5 由于不提供无扩展名文件而导致 LetsEncrypt HTTP 验证问题

.net - IIS 重定向规则优先级