The solution to let ASP.NET CORE modify the CSHTML file to take effect automatically

Background: asp.net core cannot modify the aspx page like asp.net by default, and the page will automatically take effect without stopping the operation;

But Microsoft provides a method, the method is as follows:

ps: what injection can't solve!

1. Install Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation

In the project's dependencies - packages, right click to manage NuGet packages

Search for Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation and install it

Note that the version of .net 5 is selected above 5.0

.net core 3.1 select version 3.1 or above

 

2. Add services.AddControllersWithViews().AddRazorRuntimeCompilation() in the startup file

Guess you like

Origin blog.csdn.net/qianjiu/article/details/117554109