So I am doing little refactoring in our Web API project and I noticed that it will be good to extract one of the controllers in abstract class with all needed attributes so what I did is:
extracted abstract class and method out of my existing controller:
[RoutePrefix("api/auth")] public class AdminController : BaseAdminController
So BaseAdminController
looks like this:
public abstract class BaseAdminController : BaseApiController
{
[HttpGet]
[Route("validatetoken")]
public abstract IHttpActionResult ValidateToken(string token);
}
This is the routing I use:
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/"
);
}
Now I noticed that when testing the code with abstract controller it gives throws:
No type was found that matches the controller named 'auth'
While same implementation but without abstract class and method works just fine.
I am testing with this url :
http://localhost:60747/api/auth/validatetoken?auth_token=117a2686-dad3-4b1e-a5eb-94aebed45d06