首页 新闻 会员 周边

"No service for type 'Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor' has been registered"

0
悬赏园豆:30 [已解决问题] 解决于 2018-05-19 16:54

一个 ASP.NET Core 2.1 的站点,日志中有大量下面的错误:

System.InvalidOperationException: No service for type 'Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor' has been registered.
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)

请问如何解决?

问题补充:

引发这个问题的代码:

var services = HttpContext.RequestServices;
var executor = services.GetRequiredService<ViewResultExecutor>();
var viewEngine = services.GetRequiredService<IRazorViewEngine>();
dudu的主页 dudu | 高人七级 | 园豆:31048
提问于:2018-05-18 20:59
< >
分享
最佳答案
0
dudu | 高人七级 |园豆:31048 | 2018-05-19 16:54
其他回答(2)
0
收获园豆:30
Jeffcky | 园豆:2789 (老鸟四级) | 2018-05-18 23:17
0

services.AddRazorPages();

LIUSHENGLI | 园豆:202 (菜鸟二级) | 2021-01-28 11:25
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册