CSHTML 更改需要构建,ASP.NET MVC Core 3.1 应用程序中的 JS 更改

Build required for CSHTML changes, JS changes in ASP.NET MVC Core 3.1 Applications

我最近将我的 ASP.NET MVC Core 2.2 应用程序升级到 Core 3.1,一切正常,但在调试会话中如果我对 CSHTML 文件,例如在 JS 文件中添加新的 HTML 标记或更改代码,它不会通过在本地主机调试会话上刷新应用程序来反映。我将不得不停止我的 VS 并在调试模式下重新构建和 运行。

This is happening only for ASP.NET Core 3.1 in other projects I have with ASP.NET Core 2.2 for any CSHTML changes I don't have to rebuild the solution.

我正在使用 Microsoft Visual Studio Enterprise 2019 Version 16.4.1

非常感谢任何帮助。

在 SO 上找到答案:

安装NuGetpackage Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation

更新 startup.cs 为

services.AddControllersWithViews(x=>x.SuppressAsyncSuffixInActionNames = false)
.AddRazorRuntimeCompilation();