0

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. This error happened after I implemented accept header versioning with attribute routing in a WebAPI 2 project.

Message: "An error has occurred." ExceptionMessage: "The given key was not present in the dictionary." ExceptionType: "System.Collections.Generic.KeyNotFoundException"

found here on stackoverflow:

How to get controller name when Web API versioning with routing attribues

Community
  • 1
  • 1
Rick
  • 1
  • Had the same problem. Restart of the Web Application in IIS solved this (especially after the update to WebApi 2.2 with inherit controllers) – Luuk Dec 29 '14 at 15:52

1 Answers1

0

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.

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.

Kiran
  • 56,921
  • 15
  • 176
  • 161