这个问题在这里已经有了答案:
Why does page not update after refresh when .cshtml changes
(5 个回答)
去年关闭。
我最近升级了我的 ASP.NET MVC Core 2.2 应用到 Core 3.1 ,一切正常,但在调试 session 中,如果我对 CSHTML
进行任何更改文件,例如添加新的 HTML 标记或更改 JS 文件中的代码,它不会通过在本地主机调试 session 上刷新应用程序来反射(reflect)。我将不得不停止我的 VS 并重新构建并在 Debug模式下运行。
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 上找到答案:.NET Core 3.0 - Preview 2 - Razor views don't automatically recompile on change
安装 NuGetpackage Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
更新 startup.cs
services.AddControllersWithViews(x=>x.SuppressAsyncSuffixInActionNames = false)
.AddRazorRuntimeCompilation();
关于asp.net-mvc - ASP.NET MVC Core 3.1 应用程序中的 CSHTML 更改、JS 更改所需的构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59302247/