https://translate.google.com/translate?hl=zh-CN&sl=en&u=https://blog.elmah.io/add-razor-runtime-compilation-when-developing-asp-net-core/&prev=search&pto=aue
AddRazorRuntimeCompilation 支持運行時修改razor頁面
要设置运行时编译,Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
请先安装NuGet 包:
Install-Package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
在Startup中添加
var mvcBuilder = services.AddControllersWithViews();
mvcBuilder.AddNewtonsoftJson(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());
services.AddRazorPages();
mvcBuilder.AddRazorRuntimeCompilation();