简体   繁体   English

框架 4.8 的 web.config Asp.net Web 项目中不允许使用“sameSite”属性

[英]The 'sameSite' attribute is not allowed in web.config Asp.net Web project with framework 4.8

I been trying to add sameSite = None attribute to my project cookies as a part of Chrome standards.我一直在尝试将 sameSite = None 属性添加到我的项目 cookies 作为 Chrome 标准的一部分。 I am using .net framework 4.8 and it supports sameSite for cookie ( https://learn.microsoft.com/en-us/as.net/samesite/system-web-samesite#using-samesite-in-as.net-472-and-48 ), but i am not able to do it from web.config Please help if anyone has faced similar problem and resolved that.我正在使用 .net 框架 4.8,它支持sameSite的 cookie ( https://learn.microsoft.com/en-us/as.net/samesite/system-web-samesite#using-samesite-in-as.net-472 -and-48 ),但我无法从 web.config 执行此操作 如果有人遇到类似问题并解决了该问题,请提供帮助。

This is only a warning because the attribute isn't included in Visual Studio yet.这只是一个警告,因为该属性尚未包含在 Visual Studio 中。 It shouldn't stop you compiling and will work in production because the latest browsers support it.它不应该阻止你编译并且可以在生产中工作,因为最新的浏览器支持它。

As Microsoft includes this in their official documentation I would use it as recommended and ignore the warning until an update is released with the same site parameter included.由于 Microsoft 在其官方文档中包含此内容,因此我会按照建议使用它并忽略警告,直到发布包含相同站点参数的更新为止。

<configuration>
 <system.web>
  <httpCookies sameSite="[Strict|Lax|None|Unspecified]" requireSSL="[true|false]" />
 <system.web>
<configuration>

As of Visual Studio Community 2022 Version 17.0.6 this is still not included.从 Visual Studio Community 2022 版本 17.0.6 开始,这仍然不包括在内。

(It might be safe to assume this will never get added to Visual Studio.) (假设它永远不会被添加到 Visual Studio 中可能是安全的。)

chrome://flags/#same-site-by-default-cookies chrome://flags/#same-site-by-default-cookies

Paste In Browser Url在浏览器中粘贴 Url

Disable It禁用它

Now Working fine现在工作正常

samesite=None同一站点=无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM