[英]Error with versioning with attribute routing in ASP.NET WebAPI 2
Found one example on the whole Internet of the following, and it was on StackOverflow, but there was no follow up whether it had been solved or not. 在下面的整个Internet上找到了一个示例,该示例位于StackOverflow上,但是没有解决该问题是否得到解决。 This error happened after I implemented accept header versioning with attribute routing in a WebAPI 2 project.
在WebAPI 2项目中使用属性路由实现接受标头版本控制后,发生了此错误。
Message: "An error has occurred."
消息:“发生错误。” ExceptionMessage: "The given key was not present in the dictionary."
ExceptionMessage:“字典中不存在给定的键。” ExceptionType: "System.Collections.Generic.KeyNotFoundException"
ExceptionType:“ System.Collections.Generic.KeyNotFoundException”
found here on stackoverflow: 在stackoverflow上找到此处:
How to get controller name when Web API versioning with routing attribues 带有路由属性的Web API版本控制时如何获取控制器名称
I am not sure how you implemented this as you have not shared any code, but you can take a look at the following sample demonstrating Web API's attribute routing and versioning through route constraints. 由于您尚未共享任何代码,因此不确定如何实现此目的,但是您可以查看以下示例,该示例通过路由约束演示Web API的属性路由和版本控制。
http://aspnet.codeplex.com/SourceControl/latest#Samples/WebApi/RoutingConstraintsSample/ReadMe.txt http://aspnet.codeplex.com/SourceControl/latest#Samples/WebApi/RoutingConstraintsSample/ReadMe.txt
The above sample looks for a custom header called api-version
, but you can easily modify this to suit your scenario. 上面的示例寻找一个名为
api-version
的自定义标头,但是您可以轻松地对其进行修改以适合您的情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.