dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.05k stars 9.89k forks source link

[Hot Reload] Enable hot reloading for Blazor inside an iframe #54416

Open jsakamoto opened 5 months ago

jsakamoto commented 5 months ago

Description

Hot Reload on a Blazor app doesn't work inside an iframe. See the attached video and sample code.

https://github.com/dotnet/sdk/assets/95908/6246ee11-c28a-471b-82d3-0218b1a15605

Sample code: 📦BlazorWasmApp1.zip

The solution I'd like

I know this is intentional by design, as mentioned in the pull request: https://github.com/dotnet/sdk/pull/21954. However, some edge cases exist where hot reloading support inside an iframe is essential. For instance, the clone of Storybook for Blazor, "Blazing Story" (https://github.com/jsakamoto/BlazingStory), requires such ability because it has to host a preview of the story using an iframe.

image

Therefore, I hope we have a public "escape hatch" API allowing developers to explicitly enable hot reloading inside an iframe for such a particular scenario.

jsakamoto commented 5 months ago

Related Feature Requests

See also: #39153 [Hot Reload] Enable Blazor hot reloading for multiple browser windows at the same time

The ability above is also required for the hot reloading on the "Blazing Story".

MackinnonBuck commented 5 months ago

We might be able to address this in one of two ways:

  1. Update this line to include the "frame" and "iframe" values for the Sec-Fetch-Dest header.
  2. Address this as part of https://github.com/dotnet/aspnetcore/issues/45213