一位不愿透露姓名的崔先生
2020-04-12 10:30
System.InvalidOperationException
HResult=0x80131509
Message=Unable to find the required services. Please add all the required services by calling 'IServiceCollection.AddMvc' inside the call to 'ConfigureServices(...)' in the application startup code.
Source=Microsoft.AspNetCore.Mvc.Core
StackTrace:
at Microsoft.AspNetCore.Builder.MvcApplicationBuilderExtensions.VerifyMvcIsRegistered(IApplicationBuilder app)
at Microsoft.AspNetCore.Builder.MvcApplicationBuilderExtensions.UseMvc(IApplicationBuilder app, Action`1 configureRoutes)
at Microsoft.AspNetCore.Builder.MvcApplicationBuilderExtensions.UseMvcWithDefaultRoute(IApplicationBuilder app)
at Lanzhoulamian.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in C:\Users\Administrator\Desktop\Lanzhoulamian\Lanzhoulamian\Startup.cs:line 27
?很强的学习能力!
services.AddMvc(options => options.EnableEndpointRouting = false),添加这条确实可以解决该问题,谢谢!
通过查找百度找到问题了!
在ASP.NET Core 2.2中,新增了一种路由,叫做Endpoint
(终结点)路由。本文将以往的路由系统称为传统路由
。
本文通过源码的方式介绍传统路由和Endpoint
路由部分核心功能和实现方法,具体功能上的差异见官方文档。
在升级到ASP.NET Core 2.2后,会自动启用Endpoint
路由
public void ConfigureServices(IServiceCollection services)
{
//添加
services.AddMvc(options => options.EnableEndpointRouting = false)
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
打造你的第一个ASP.NET5 MVC网站应用
19277 学习 · 194 问题
相似问题