没有注册类型为“ Microsoft.AspNetCore.Mvc.Cors.CorsAuthorizationFilter”的服务

时间:2019-02-19 14:54:13

标签: c# asp.net-core asp.net-core-2.0

当我尝试运行ASP.NET Core应用程序时遇到了此问题。最近,我已经从ASP.NET Core 1.0迁移到了2.2.0。

  

Microsoft.AspNetCore.Server.Kestrel [13]         连接ID“ 0HLKMF5LL7VBF”,请求ID“ 0HLKMF5LL7VBF:00000002”:应用程序引发了未处理的异常。   System.InvalidOperationException:没有注册类型'Microsoft.AspNetCore.Mvc.Cors.CorsAuthorizationFilter'的服务。      在Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider提供者,类型serviceType)      在Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService [T](IServiceProvider提供程序)      在Microsoft.AspNetCore.Mvc.Cors.Internal.CorsAuthorizationFilterFactory.CreateInstance(IServiceProvider serviceProvider)      在Microsoft.AspNetCore.Mvc.Internal.DefaultFilterProvider.ProvideFilter(FilterProviderContext上下文,FilterItem filterItem)      在Microsoft.AspNetCore.Mvc.Internal.DefaultFilterProvider.OnProvidersExecuting(FilterProviderContext上下文)      在Microsoft.AspNetCore.Mvc.Internal.FilterFactory.CreateUncachedFiltersCore(IFilterProvider [] filterProviders,ActionContext actionContext,List`1 filterItems)中      在Microsoft.AspNetCore.Mvc.Internal.FilterFactory.GetAllFilters(IFilterProvider [] filterProviders,ActionContext actionContext)      在Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvokerCache.GetCachedResult(ControllerContext controllerContext)      在Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvokerProvider.OnProvidersExecuting(ActionInvokerProviderContext上下文)      在Microsoft.AspNetCore.Mvc.Internal.ActionInvokerFactory.CreateInvoker(ActionContext actionContext)      在Microsoft.AspNetCore.Mvc.Internal.MvcAttributeRouteHandler。<> c__DisplayClass12_0.b__0(HttpContext c)      在Microsoft.AspNetCore.Builder.RouterMiddleware.d__4.MoveNext()

0 个答案:

没有答案