ASP.NET MVC Core 3.1 应用程序中的 CSHTML 更改、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 并重新构建并在调试模式下运行.
I have recently upgraded my ASP.NET MVC Core 2.2 application to Core 3.1, everything works well, but in debug sessions if I make any changes to CSHTML
file, like adding a new HTML tag or change code in JS file, it doesn't reflect by refreshing the app on localhost debug session. I will have to stop my VS and re-build and run in debug mode.
这仅发生在我拥有的其他项目中的 ASP.NET Core 3.1使用 ASP.NET Core 2.2 进行任何 CSHTML 更改,我不必重新构建解决方案.
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 版本 16.4.1
非常感谢任何帮助.
推荐答案
在 SO 上找到答案:.NET Core 3.0 - Preview 2 - Razor 视图不会在更改时自动重新编译
Found answer on SO: .NET Core 3.0 - Preview 2 - Razor views don't automatically recompile on change
安装NuGetpackage Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
用
services.AddControllersWithViews(x=>x.SuppressAsyncSuffixInActionNames = false)
.AddRazorRuntimeCompilation();
这篇关于ASP.NET MVC Core 3.1 应用程序中的 CSHTML 更改、JS 更改所需的构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!