.NET Core MVC Page Not Refreshing After Changes

In ASP.NET Core 3.0 and higher, RazorViewEngineOptions.AllowRecompilingViewsOnFileChange is not available.

Surprised that refreshing a view while the app is running did not work, I discovered the following solution:

  1. Add Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation NuGet package to the
    project

  2. Add the following in Startup.cs:

    services.AddControllersWithViews().AddRazorRuntimeCompilation();
    

Here’s the full explanation for the curious.

Leave a Comment