.NET CORE AddRazorRuntimeCompilation

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();

 

上一篇:一、什么是Razor


下一篇:深入浅出Blazor webassembly之razor组件的C#代码组织形式