带有Dynamic Cultureinfo的Blazor Server应用程序保存在cookie中

发布于 2025-01-29 17:28:46 字数 790 浏览 4 评论 0 原文

我无法共享我自己的NDA问题应用程序,但是我发现了这个完全相同的问题

https://github.com/SyncfusionExamples/blazor-localization/tree/master/.NET6%20Blazor%20Server%20App/Localization-with-动态培养 blazor-localization

此应用程序以 culturesWitcherSwitcherwitcher 组件显示页面在5种语言之间选择。

选择一种语言时,我可以看到Page+下拉词都用所选语言值刷新。

现在,您将此应用程序的URL嵌入了新应用程序的页面中,而无效。

cookie机制不再保存或/和加载值。

这在Net+Core+3.1和5.0中完美工作,但在Net+Core+6中不再工作。

安全性或CORS还是???

预先感谢您的任何提示

-

I can't share my own app for nda issue but I found this one which shows exactly the same issue

https://github.com/SyncfusionExamples/blazor-localization/tree/master/.NET6%20Blazor%20Server%20App/Localization-with-dynamic-culture
Blazor-Localization

This app displays a page with a CultureSwitcher component to select between 5 languages.

When you select a language, I can see both the page+dropdown refreshed with the selected language value.

Now, you embed the Url of this app inside a new app's page inside an iFrame and nothing works anymore.

The cookie mechanism doesn't save or/and load the value anymore.

This was working perfectly in net+core+3.1 and 5.0 but no more in net+core+6.

Is something change in security or cors or ????

Thanks in advance for any tips

-Vince

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

‘画卷フ 2025-02-05 17:28:47

这听起来像是Samesite Cookie的问题。它甚至被记录为在这里

使用< iframe>的应用程序可能会遇到Samesite = Lax的问题
或samesite =严格的饼干,因为被视为跨站点
方案。

您是否尝试过设置Cookie选项?

HttpContext.Response.Cookies.Append(
    CookieRequestCultureProvider.DefaultCookieName,
    CookieRequestCultureProvider.MakeCookieValue(
       new RequestCulture(culture)),
    new CookieOptions() { SameSite = SameSiteMode.None, Secure = true} );

This sounds like an issue with SameSite cookies. It's even documented here:

Applications that use <iframe> may experience issues with sameSite=Lax
or sameSite=Strict cookies because is treated as cross-site
scenarios.

Have you tried setting the cookie options?

HttpContext.Response.Cookies.Append(
    CookieRequestCultureProvider.DefaultCookieName,
    CookieRequestCultureProvider.MakeCookieValue(
       new RequestCulture(culture)),
    new CookieOptions() { SameSite = SameSiteMode.None, Secure = true} );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文