上下文
在我的 .NET Framework 4.x ASP.NET MVC 项目中,使用 Visual Studio IDE 时,可以编辑 .cshtml
View ,保存,然后按 ctrl+F5 在浏览器中立即看到更改。
这似乎不再适用于 ASP.NET Core 应用程序(使用 Visual Studio 2019 和 .NET Core 3 Preview 5)。
问题
ASP.NET Core 中缺少此功能吗?这是预览问题吗?或者我错过了什么?
最佳答案
从 ASP.NET Core 3 开始,默认情况下不再启用此功能,但可以按照文档 here 重新启用它。 :
Runtime compilation is enabled using the
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
package. To enable runtime compilation, apps must:
Install the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation NuGet package.
Update the project's
Startup.ConfigureServices
method to include a call toAddRazorRuntimeCompilation
:services .AddControllersWithViews() .AddRazorRuntimeCompilation();
关于asp.net-core - 是否可以使用 .NET Core 更改 .cshtml View 并立即查看更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56042058/