Forum Discussion

vrithner_vmmlog's avatar
vrithner_vmmlog
Copper Contributor
May 17, 2022

Blazor Server App with Dynamic CultureInfo Saved in Cookie don't work in iFrame anymore

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

https://github.com/tossnet/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 mecanism doesn't save or/and load the value anymore.

This was working perflecly 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

 

 

 

2 Replies

  • LanHuang's avatar
    LanHuang
    Iron Contributor

    Hi vrithner_vmmlog,

    Thanks for posting your issue here.

    However this platform is used for how-to discussions and sharing best practices for building any app with .NET.Since your issue is a technical question, welcome to post it in Microsoft Q&A forum, the support team and communities on Microsoft Q&A will help you for any technical questions.
    Besides, it will be appreciated if you can share it here once you post this technical question Microsoft Q&A.
    Best Regards,
    Lan Huang

    • vrithner_vmmlog's avatar
      vrithner_vmmlog
      Copper Contributor
      Hi,
      it's all linked to enhancement of the browsers security stuff (specially Chrome and Edge); apparently, the old implement sill works in FF.
      After getting help, the best practice to embed Url endpoints into iFrames is to follow this post from you guys : https://docs.microsoft.com/en-us/aspnet/samesite/system-web-samesite

      In fact, I just had to add the last line to make it work:
      HttpContext.Response.Cookies.Append(
      CookieRequestCultureProvider.DefaultCookieName,
      CookieRequestCultureProvider.MakeCookieValue(
      new RequestCulture(culture)),
      new CookieOptions() { SameSite = SameSiteMode.None, Secure = true} );

      Hopes it will help people with same issue.
      Txs
      Best Regards
      -vince

Resources