When building a RESTful API, it is desirable to issue return codes of 406 (not acceptable) and 415 (Unsupported media type) when doing content negotiation.
What is not clear to me is exactly how to return these codes in a WebAPI2 app that is using attribute routing.
I have seen examples on how to use ActionMethodSelectorAttribute and RouteFactoryAttribute to create custom route selectors, but when a route cannot be found due to an Accept or Content-Type mismatch, the automatic response is a 404 Not found error, which does not fully explain the problem.
What I would like to do is capture WHY a route could not be found, and if it is due to a content type negotiation failure, return the appropriate 406 or 415 response code.
Is there an example anywhere that shows how to do this?