Hot reload isn't working - aspnetcore-browser-refresh.js isn't being injected into the page
See original GitHub issueIs 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:
- Created a year ago
- Comments:39 (38 by maintainers)
Top Related StackOverflow Question
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 ofapp.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.
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!