为了账号安全,请及时绑定邮箱和手机立即绑定

我用的也是2.2,出现异常!

http://img1.sycdn.imooc.com/5e927d0000011ceb09890308.jpg

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


?很强的学习能力!

2020-04-15
0

通过查找百度找到问题了!

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

        }


2020-04-12
0

services.AddMvc(options => options.EnableEndpointRouting = false),添加这条确实可以解决该问题,谢谢!

2020-05-17
0

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信