升级到sitecore 8后WEB API调用出现500错误

升级到sitecore 8后WEB API调用出现500错误,sitecore,upgrade,asp.net-web-api-routing,sitecore-mvc,Sitecore,Upgrade,Asp.net Web Api Routing,Sitecore Mvc,最近,我们从Sitecore 7.5升级到Sitecore 8.0。升级后,自定义Web API调用开始返回500个错误代码,但以下情况除外: Message:"An error has occurred." ExceptionMessage:"ValueFactory attempted to access the Value property of this instance." ExceptionType:"System.InvalidOperationException" StackTr

最近,我们从Sitecore 7.5升级到Sitecore 8.0。升级后,自定义Web API调用开始返回500个错误代码,但以下情况除外:

Message:"An error has occurred."
ExceptionMessage:"ValueFactory attempted to access the Value property of this instance."
ExceptionType:"System.InvalidOperationException"
StackTrace:"   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.GetControllerMapping()
   at System.Web.Http.Routing.AttributeRoutingMapper.AddRouteEntries(SubRouteCollection collector, HttpConfiguration configuration, IInlineConstraintResolver constraintResolver, IDirectRouteProvider directRouteProvider)
   at System.Web.Http.Routing.AttributeRoutingMapper.<>c__DisplayClass2.<>c__DisplayClass4.<MapAttributeRoutes>b__1()
   at System.Web.Http.Routing.RouteCollectionRoute.EnsureInitialized(Func`1 initializer)
   at System.Web.Http.Routing.AttributeRoutingMapper.<>c__DisplayClass2.<MapAttributeRoutes>b__0(HttpConfiguration config)
   at System.Web.Http.CorsHttpConfigurationExtensions.<>c__DisplayClass3.<AddCorsMessageHandler>b__0(HttpConfiguration config)
   at System.Web.Http.HttpConfiguration.ApplyControllerSettings(HttpControllerSettings settings, HttpConfiguration configuration)
   at System.Web.Http.Controllers.HttpControllerDescriptor.InvokeAttributesOnControllerType(HttpControllerDescriptor controllerDescriptor, Type type)
   at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.InitializeControllerInfoCache()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.GetControllerMapping()
   at System.Web.Http.Routing.AttributeRoutingMapper.AddRouteEntries(SubRouteCollection collector, HttpConfiguration configuration, IInlineConstraintResolver constraintResolver, IDirectRouteProvider directRouteProvider)
   at System.Web.Http.Routing.AttributeRoutingMapper.<>c__DisplayClass2.<>c__DisplayClass4.<MapAttributeRoutes>b__1()
   at System.Web.Http.Routing.RouteCollectionRoute.EnsureInitialized(Func`1 initializer)
   at System.Web.Http.Routing.AttributeRoutingMapper.<>c__DisplayClass2.<MapAttributeRoutes>b__0(HttpConfiguration config)
   at System.Web.Http.CorsHttpConfigurationExtensions.<>c__DisplayClass3.<AddCorsMessageHandler>b__0(HttpConfiguration config)
   at System.Web.Http.HttpConfiguration.ApplyControllerSettings(HttpControllerSettings settings, HttpConfiguration configuration)
   at System.Web.Http.Controllers.HttpControllerDescriptor.InvokeAttributesOnControllerType(HttpControllerDescriptor controllerDescriptor, Type type)
   at Sitecore.Services.Infrastructure.Web.Http.Dispatcher.NamespaceHttpControllerSelector.InitializeControllerDictionary()
   at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
   at System.Lazy`1.get_Value()
   at Sitecore.Services.Infrastructure.Web.Http.Dispatcher.NamespaceHttpControllerSelector.SelectController(HttpRequestMessage request)
   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
在尝试升级时为我们工作。你应该完整阅读这篇文章以了解它在做什么,但简言之,你需要创建一个定制的HttpControllerSelector,并在Sitecore添加所有路由后将其与Sitecore交换。注:本摘要均不是我的。我从链接文章中收集了所有这些信息


作为补充说明,我强烈建议避免对Sitecore 8进行就地升级。我想说,使用新安装的Sitecore 8,然后通过软件包迁移您的内容几乎总是一个更好的选择。这是两种选择的绝佳选择

最好在回答中提供解决方案的摘要,请参阅我提供的两个链接的上下文。此外,我不会剽窃或窃取别人的作品。我们使用了那篇文章来解决问题,我不打算复制粘贴到这里。这对我来说很有效,但我需要添加以下内容:
public override IDictionary GetControllerMapping(){return\u controllers;}
CustomHttpControllerSelector