.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();重新运行即可