asp.net-core - 是否可以使用 .NET Core 更改 .cshtml View 并立即查看更改?

标签 asp.net-core razor asp.net-core-3.0

上下文

在我的 .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 to AddRazorRuntimeCompilation:

     services
         .AddControllersWithViews()
         .AddRazorRuntimeCompilation();
    

关于asp.net-core - 是否可以使用 .NET Core 更改 .cshtml View 并立即查看更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56042058/

相关文章:

c++ - Asp.Net Core Dependency Injection 不起作用,如果它是从非托管/ native 启动的

asp.net-mvc - Asp.Net core Razor Taghelpers - 强制参数

c# - 将 html 帮助程序迁移到 ASP.NET Core

.net-core - 无法访问 Blazor Server 3.0 中已处置的对象

azure - 使用 Azure Active Directory 和 Azure Active Directory B2C 时如何获取标准 OpenID 连接声明?

c# - Azure CosmosDB Contains 方法不起作用

asp.net-mvc - 带有下拉菜单的动态年份绑定(bind)

c# - 无法连接到网络服务器 'IIS Express'

mysql - .NET Core 添加迁移忽略一些属性

c# - ASP.NET 5 类库可以面向 .NET 3.5 吗?