Visual studio not refreshing changes in browser on reload
Issue with .Net core 3.1
So, this issue mainly comes while working with .Net core. However solutions can be bit different in earlier versions of .Net core and after version 3.1. So we will see how to fix that for .Net core 3.1.
First of all, for fixing this issue we have to add a missing NuGet package in our project. For that , navigate to
Project ->Manage NuGet Packages
as shown in the image below :-
Now you have to find a package named Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation . You can have a look at the image below.
So, for avoiding compatibility issues we will be using slightly older version for this. As you can see we have used version 3 for this. After selecting that version, click on Install.
Now after your installation is completed . You can move to the last step. You have to add two lines in ConfigureServices Method.You can see in the screenshot below. Add this line to your startup.cs.
IMvcBuilder builder = services.AddRazorPages(); builder.AddRazorRuntimeCompilation();
After adding these lines, now just rebuild your project and run. And this time your changes will be refreshed on browser reload. So this is how we can fix visual studio reload issue in .Net core 3.1.