4

I would like all controllers which inherit from AdminBaseApiController to be prefixed with 'admin'.

This works fine of course:

[RoutePrefix("admin")]
public class ToggleController : AdminBaseApiController
{
    [Route("toggle")]
    public HttpResponseMessage Get()
    {
    }
}

However when I move the RoutePrefix("admin") out of the ToggleController and into the AdminBaseApiController (where I want it) - The route fails and I get a 404.

Am I looking at this all wrong? Thanks in advance!

Marc Costello
  • 439
  • 1
  • 3
  • 12
  • 3
    [this answer](http://stackoverflow.com/questions/19989023/net-webapi-attribute-routing-and-inheritance) pretty much sums it up. And the documentation about halfway down [this page](http://www.asp.net/web-api/overview/releases/whats-new-in-aspnet-web-api-22) – Jonesopolis Jul 31 '14 at 12:51

1 Answers1

9

Support for inheritance has been enabled in Web API 2.2 release...You can take a look at an example in the following Release Notes:

http://www.asp.net/web-api/overview/releases/whats-new-in-aspnet-web-api-22#ARI

Kiran
  • 56,921
  • 15
  • 176
  • 161