Paul
Paul

Reputation: 1006

.net 6 blazor wasm hot reload not working

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. enter image description here

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

Answers (7)

khaled younes
khaled younes

Reputation: 41

On Blazor Icon (Next to debug icon) click on hot reload on file save, it should work now.

the red icon like firefox icon

Upvotes: 3

John
John

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

VeganHunter
VeganHunter

Reputation: 5974

It seems that Hot Reload works only in certain configurations:

  • When I host the app in IIS Express - hot reload works, even in Debug mode.
  • When I host the app in Docker, hot reload does NOT work neither with or without debugger.

I had tested in Visual Studio v17.2.2 (although v17.1.2 should be sufficient)

Upvotes: 1

Martin Smith
Martin Smith

Reputation: 129

Just try restarting Visual Studio, if it suddenly stops working.

Upvotes: 7

Abi Chhetri
Abi Chhetri

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

enter image description here

Note: Help -> Check for updates

Upvotes: 1

Ben D
Ben D

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

Paul
Paul

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

Related Questions