运行时编译

当 .cshtml 文件的内容发生更改时,ASP.NET Core MVC 将重新编译 Razor 文件 。

AllowRecompilingViewsOnFileChange 获取或设置一个值,该值确定当磁盘上的文件发生更改时是否重新编译和更新 Razor 文件(Razor 视图和 Razor Pages)。

对于以下项,默认值为 true

  • Version_2_1 或更早版本
  • AllowRecompilingViewsOnFileChange,否则 Razor 文件不会在非开发环境中重新编译。

ASP.NET Core MVC 的兼容性版本。

要启用运行时编译,应用必须:

  • Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation NuGet 包。

  • 将项目的 Startup.ConfigureServices 方法更新为包含对 AddRazorRuntimeCompilation 的调用:

    services
        .AddControllersWithViews()
        .AddRazorRuntimeCompilation();
    
  •  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-12
  • 2021-06-03
  • 2022-02-28
  • 2021-10-01
猜你喜欢
  • 2022-12-23
  • 2021-06-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
相关资源
相似解决方案