Hot Reload not working in Visual Studio 2022 .Net 6 Razor projects
Asked Answered
M

6

18

We just upgraded all but one of our web app projects from .NET Core 3.1 projects to .NET 6 in our solution. These were ASP.NET Core 3.1 projects using Razor. Here are the results we're seeing with respect to Hot Reload:

  1. The .NET 6 projects hot reload doesn't seem to work. Hot Reload is enabled, but our Front End is never updated. Refreshing the page doesn't seem to show the updates either.
  2. The ASP.NET Core 3.1 project hot reload is working as expected.

When we run these projects in VS 2019, we can refresh the pages in any of our projects and we will see the updates. Are there some settings that we're missing here?

Malva answered 18/5, 2022 at 23:6 Comment(2)
What exactly is not reloading? If it is razor views - try answers for this question.Decemvir
You're a life saver! This is our solution. We hadn't updated RazorRuntimeCompilation and we needed to and one setting in launchsettings.json. This has been the reason why we've been hesitant to move onto VS 2022. Thank you!Malva
M
16

Big Thank you to Guru Stron! His comment in my question directed me to where I should've looked. We had to:

  1. Update our Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation Nuget package
  2. Add this to our launchsettings.json: ASPNETCORE_HOSTINGSTARTUPASSEMBLIES to "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"

This answer solved our issue - .NET Core MVC Page Not Refreshing After Changes

Malva answered 19/5, 2022 at 16:54 Comment(2)
For me the NuGet package was enoughAccordion
Hmm.... I'm having this trouble with an MVC app and trying to fix. I don't even have that package. Anyone know hot to fix for MVC?Sagunto
C
15

First, Make sure all options are selected

enter image description here

In Hot reload, You can select Hot Reload On File Save(Not selected by default), Then VS will hot reload after you ctrl+s;

enter image description here

Demo

enter image description here

Cymbal answered 19/5, 2022 at 1:45 Comment(2)
Thanks for the reply. Unfortunately, we've tried this and it still doesn't work for us.Malva
I think checking the third hot reload option in Tools options worked for me in my MVC app. Thank you.Sagunto
S
2

I had the same issue and the following steps fixed it.

  1. Close Visual Studio and delete all the bin and obj folders in your solution.
  2. Remove .vs (hidden) folder in the solution root.

And this is my (default) Hot Reload settings: Hot Reload settings

Hope this might help someone.

Straightlaced answered 21/12, 2023 at 15:45 Comment(0)
S
1

I had the same issue and after trying everything including rolling back the version and adding .AddRazorRuntimeCompilation() to Program.cs still didn't work. What I did was literally re-check the "Hot reload on file save" option when you click on the down arrow to bring up the menu on the hot reload button from the menu bar. That did the trick for me.

Hopefully this works for you.

Sinus answered 31/7, 2022 at 6:16 Comment(0)
S
1

Apart from all the other good suggestions, my case was different.

I had the same issue. There were 2 projects running, and the first one was the API. After starting the API project separately (right-click on the Project name, Debug>Start..) the only project I actually ran was my Blazor WASM. Then the Hot Reload started to work for the Blazor WASM project.

Hope it helps, if anyone has a similar issue.

Steen answered 13/10, 2023 at 13:46 Comment(0)
T
0

In my project, I deselect 'Enable native code debugging' then Hot reload working: Project > Properties > Debug > General > Open debug launch profiles UI > IIS Express.

enter image description here

Tertial answered 27/12, 2023 at 3:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.