Question: Why is dotnet watch run not showing changes in the View or Razor Pages. Every time I make a change to the View or the Razor Page "dotnet watch run does not work".
Any idea on how to solve this problem?
Login to See the Rest of the Answer
Answer: The dotnet watch run works with Razor pages or Views when you only specify so in your project. Follow steps below to have dotnet watch run work with Asp.Net Views and Razor Page.
1. If you're using Asp.Net Core 6 also known as AspNet 6
- Add builder.Services.AddRazorPages().AddRazorRuntimeCompilation();
- Add builder.Services.AddHttpContextAccessor();
2. Find the launchSettings.json file used to specify the the profiles of the RunTime or Running Enviroment
- Add the following Enviroment Variable
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
Give your project a build and clean the Solution. Test the dotnet watch run compiling with the Razor or View pages and give this article a thumbs up and leave a comment below.