Reputation: 1006
I'm using Visual Studio 2022 and created a new Blazor webassembly app and ran it. The option for hot reload on file save is checked.
If I make changes in the Counter component (either HTML or C# code changes) and save the file I see a tick symbol appear at the top left of the browser but neither of the changes have kicked in, the browser just continues with the old version.
After the change the counter still increments even though I changed it to decrement and the h1 title doesnt include the 2 after it.
Upvotes: 13
Views: 14974
Reputation: 41
On Blazor Icon (Next to debug icon) click on hot reload on file save, it should work now.
Upvotes: 3
Reputation: 7049
Another thing to check is that "hot reload on file save" is actually on if like me that's what you rely on.
It can be found in the menu on the flame icon.
I somehow managed to turn that off without knowing and didn't even realize there was a hot reload button.
Upvotes: 1
Reputation: 5974
It seems that Hot Reload works only in certain configurations:
I had tested in Visual Studio v17.2.2 (although v17.1.2 should be sufficient)
Upvotes: 1
Reputation: 129
Just try restarting Visual Studio, if it suddenly stops working.
Upvotes: 7
Reputation: 1437
I was using the visual studio IDE 2022 v17.0.1
Updated the visual studio IDE 2022 to v17.1.2 supported the blazor hot reload
Note: Help -> Check for updates
Upvotes: 1
Reputation: 811
I can confirm what The Thirsty Ape suggested works when running Visual Studio 2022 and .NET 6
dotnet watch --project .\your-project-name-here.csproj
The browser will launch and the console should display something like:
watch : Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload. Press "Ctrl + R" to restart.
And finally after making a code change:
watch : Hot reload of changes succeeded.
No refresh is required
Upvotes: 4
Reputation: 1006
So i've worked out that it only works if you run the project without debugging, not with debugging.
Ctrl + F5 (hot reload works), F5 (doesn't work)
Upvotes: 12