Hot reload isn't working - aspnetcore-browser-refresh.js isn't being injected into the page

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

My team and I have not had any luck with hot reload since moving to .NET 6. Out of the 5 of us, we use a mix of Visual Studio 2022, Rider, the dotnet CLI, Windows and Mac and not one of us has managed to get hot reload working. We have a Blazor Wasm Hosted solution, with a few additional class libraries.

When we run dotnet watch and make a change to a component, say adding a class, it hangs with File changed: <file name> and then nothing. The only way to recover is to cancel the watch with ctrl+c and start again.

We’ve been struggling to find something that was going to be useful in an issue, but we finally noticed something yesterday. The aspnetcore-browser-refresh.js isn’t being injected into our applications host page (index.html). If we manually add a reference to the file, then things get a little better. The watch doesn’t hang but it will only perform a rebuild and reload and not a hot reload. But this usually results in the browser freezing–I’m guessing because it wasn’t injected and something isn’t setup correctly.

If there is any additional info I can provide, pleased let me know.

Expected Behavior

Hot reload should work.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

6.0.300

Anything else?

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:39 (38 by maintainers)

github_iconTop GitHub Comments

2reactions
stany9gcommented, Jul 13, 2022

Hello guys,

I hit this issue as well. Pretty much the same case - migration from .net 5 to .net 6. I have manually added the <script src="_framework/aspnetcore-browser-refresh.js"></script> and it started to work (even the changes are applied really slowly). Removal of app.UseResponseCompression(); did not help by itself. A Blazor hosted server is using http.sys.

Can you please advise some steps I should try to make it work out of the box or this workaround of manually adding the .js file is the way to go?

Thank you very much.

0reactions
msftbot[bot]commented, Sep 11, 2022

Thank you for contacting us. Due to a lack of activity on this discussion issue we’re closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn’t been addressed yet, please file a new issue.

This issue will be locked after 30 more days of inactivity. If you still wish to discuss this subject after then, please create a new issue!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disabling Hot Reload for .NET Core project in Visual ...
Options to automatically build and refresh the browser if the web server is ... the injection of the aspnetcore-browser-refresh.js script.
Read more >
What is aspnetcore-browser-refresh.js and how can I stop ...
VS 2022 keeps adding client side scripts to my projects. I am spending a lot of time trying to debug them and prevent...
Read more >
Unable to use hot reload while debugging Blazor WASM ...
The browser refresh script is injected into my html. <script src="/_framework/aspnetcore-browser-refresh.js"></script>.
Read more >
Live Reloading Server And Client Side ASP.NET Core Apps ...
Client side in-browser hot reloading is one of the most compelling ... a browser refresh at the time of the change isn't going...
Read more >
.NET 6 Hot Reload and "Refused to connect to ws ...
If you're excited about Hot Reload like me AND you also want an ... < script src = "/_framework/aspnetcore-browser-refresh.js" ></ script > ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found