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

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) Commented Dec 29, 2014 at 15:52

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Not doing anything fancy. I will post the code a few minutes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.