Why doesn't Razor automatically recompile after save when using .NET 6.0?

Viewed 346

I was unhappy after moving to .NET 6 when I discovered that changes I made to the razor weren't being automatically compiled after clicking save. I spent months having to restart the whole web server every time I made a small change to the site I'm developing. I scoured the internet looking for a solution and even communicated with a Microsoft team member, all to no avail.

Luckily, my coworker stumbled into a solution that works perfectly and I wanted to share it with other people who are having the same issue.

1 Answers

Just add this library to the project file and it'll start working.

<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.1" />
Related