我使用 .NET 4.5 开发了一个简单的 VB .NET Web API 项目
该项目运行良好,但我决定安装AttributeRouting nuget 包。安装此软件包后,每个功能似乎都会引发以下异常:
具有路由模板“Company”的路由上的约束条目“inboundHttpMethod”必须具有字符串值或实现“IHttpRouteConstraint”的类型。
在此消息中,“Company”是一个简单的 GET 方法的路由名称,该方法简单地返回一个对象。每条路线都会导致此错误消息。堆栈跟踪是:
[InvalidOperationException:具有路由模板'Company/{Id}'的路由上的约束条目'inboundHttpMethod'必须具有字符串值或实现'IHttpRouteConstraint'的类型。]
System.Web.Http.Routing.HttpRoute.ProcessConstraint (HttpRequestMessage 请求,对象约束,字符串参数名称,HttpRouteValueDictionary 值,HttpRouteDirection routeDirection)+346 System.Web.Http.Routing.HttpRoute.ProcessConstraints(HttpRequestMessage 请求,HttpRouteValueDictionary 值,HttpRouteDirection routeDirection)+201
System.Web.Http.Routing.HttpRoute .GetRouteData(String virtualPathRoot, HttpRequestMessage request) +430
AttributeRouting.Web.Http.Framework.HttpAttributeRoute.GetRouteData(String virtualPathRoot,HttpRequestMessage 请求)+250
System.Web.Http.WebHost.Routing.HttpWebRoute.GetRouteData(HttpContextBase httpContext) +191
System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) +233
System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +60
System .Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +82
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
我发现以下线程描述了我的问题:https ://github.com/mccalltd/AttributeRouting/issues/191
不幸的是,这个修复似乎没有帮助:https ://github.com/mccalltd/AttributeRouting/issues/191#issuecomment-13814025
有想法该怎么解决这个吗?