Skip to content

Blazor WebAssembly Hot Reload does not work if body tag is incorrect #38454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
trevorcode opened this issue Nov 16, 2021 · 3 comments
Open
Labels
area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI bug This issue describes a behavior which is not expected - a bug. feature-dotnetwatch This issue is related to the dotnet-watch command-line tool (now external) feature-hot-reload This issue is related to the Hot Reload feaature
Milestone

Comments

@trevorcode
Copy link

Blazor WebAssembly Hot Reload does not work when the HTML body tag is not correct. This may not be a bug, but it threw no errors and was frustrating to debug.

This occurred when I was upgrading a project from .NET 5 to .NET 6.

When a change was made, the hot reload would detect that a file was changed.
watch : File changed: C:\Users\trevo\...etc
However, it would be stuck at never apply the updates to the UI.

My body tag in my index.html was configured incorrectly. It had an extra space at the end of the body tag.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>EmptyBlazor6App</title>
    <base href="/" />
    <link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
    <link href="css/app.css" rel="stylesheet" />
    <link href="EmptyBlazor6App.Client.styles.css" rel="stylesheet" />
</head>

<body>
    <div id="app">Loading...</div>

    <div id="blazor-error-ui">
        An unhandled error has occurred.
        <a href="" class="reload">Reload</a>
        <a class="dismiss">🗙</a>
    </div>
    <script src="_framework/blazor.webassembly.js"></script>
</body > <!--THE ISSUE IS RIGHT HERE-->

</html>

</body >
Should have been:
</body>

This is more hopefully just an FYI as opposed to something that perhaps a direct bug.

To Reproduce

  1. Create a new Blazor WebAssembly project
  2. Incorrectly configure your body tag on your index.html to have an extra space at the end.
  3. Witness hot reload not work

Further technical details

  • .NET version: 6.0
  • using dotnet watch

Fixes/Workarounds

Make sure the tags don't have any extra space in them so that the Hot Reload Deltas can be correctly applied.

@TanayParikh TanayParikh added area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-hot-reload This issue is related to the Hot Reload feaature labels Nov 16, 2021
@pranavkm pranavkm added area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI feature-dotnetwatch This issue is related to the dotnet-watch command-line tool (now external) and removed area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly labels Nov 17, 2021
@pranavkm
Copy link
Contributor

Thanks for the heads up. We think fixing the bug is hard, but we can log a warning that would indicate that we failed to inject the script.

@pranavkm pranavkm added this to the .NET 7 Planning milestone Jan 21, 2022
@ghost
Copy link

ghost commented Jan 21, 2022

Thanks for contacting us.

We're moving this issue to the .NET 7 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@pranavkm pranavkm added the bug This issue describes a behavior which is not expected - a bug. label Jan 21, 2022
@mkArtakMSFT mkArtakMSFT modified the milestones: .NET 7 Planning, Backlog Jun 22, 2022
@ghost
Copy link

ghost commented Jun 22, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI bug This issue describes a behavior which is not expected - a bug. feature-dotnetwatch This issue is related to the dotnet-watch command-line tool (now external) feature-hot-reload This issue is related to the Hot Reload feaature
Projects
None yet
Development

No branches or pull requests

5 participants
@pranavkm @TanayParikh @mkArtakMSFT @trevorcode and others