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?
Please 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
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.