ASP.NET Web API extending DefaultDirectRouteProvider

1.4k views Asked by At

I'm trying to create a CustomerDefaultDirectRouteProvider that extends DefaultDirectRouteProvider in Web API 2.2, as in this example. However, when I implement the method GetActionRouteFactories(HttpActionDescriptor actionDescriptor), I get the error "no suitable method found to override".

I am able to override GetActionRouteFactories(ActionDescriptor actionDescriptor), but the ActionDescriptor class does not have the method GetCustomAttributes<IDirectRouteFactory>.

I am importing the following namespaces:

using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Mvc.Routing;
using System.Web.Routing;
using System.Web.Http.Controllers;

Am I missing some, perhaps?

1

There are 1 answers

0
huysentruitw On BEST ANSWER

You are mixing MVC and WebAPI. Both have the DefaultDirectRouteProvider class. I suggest you remove the .Mvc-namespaces and use the one from System.Web.Http.Routing.