.Net Core 前端运行时编译无效的解决方法

官方文档:https://docs.microsoft.com/zh-cn/aspnet/core/mvc/views/view-compilation?view=aspnetcore-3.0&tabs=visual-studio

1.首先需要安装运行时编译包;  直接下载地址:  https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation/;也可以复制命名空间在nuget下自主安装;

Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation

2.修改Properties下单launchSettings.json;在environmentVariables节点下添加  ASPNETCORE_HOSTINGSTARTUPASSEMBLIES,并设置为 "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" 即可;

"environmentVariables": {
 "ASPNETCORE_ENVIRONMENT": "Development",
 "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
}

 

 

 3.在Startup=>ConfigureServices,添加   services.AddRazorPages().AddRazorRuntimeCompilation();重新运行即可

 

posted @ 2021-09-14 11:17  云水边静沐暖阳丶  阅读(334)  评论(0编辑  收藏  举报