There was exactly the same problem. After some research, trial and error, I was able to find a working solution.
I have a RoutePrefix solution RoutePrefix and tried to implement something similar to how MVC controllers use HandleUnknownAction in the base controller.
With this post: Routing and inheriting .NET WebAPI attributes to ensure route inheritance, I created a base controller for my web APIs using the HandleUnknownAction method for example:
public abstract class WebApiControllerBase : ApiController { [Route("{*actionName}")] [AcceptVerbs("GET", "POST", "PUT", "DELETE")]
If you do not want to follow the path of inheritance, you can always put the method directly in the controller to which you want to apply functionality.
This allows me to use route prefixes that process user-found messages that are specific to certain controllers, since I have both a back office and public, public APIs.
If the URL is not ApiController , the default error controller will handle those not found as usual.
Nkosi
source share