1

I'm working on a template ApiController which is declared like this:

public class CrudApiController<TEntity> : ApiController
{
    protected IClient<TEntity> Client { get; set; }

    public CrudApiController(IClient<TEntity> client)
    {
        Client = client;
    }

    // This route is not found when I declare it with the Route attribute
    // However, if i remove it, it's found.
    [System.Web.Http.Route("Get/{objectId}")]
    public TEntity Get(int objectId)
    {
        return Client.Get(objectId);
    }
}

... And extended like this:

[System.Web.Http.RoutePrefix("api/Users")]
public class UsersController : CrudApiController<UserEntity>
{
    public UsersController() : base(new UserClient()) {}
}

I can't get the route inside CrudApiController to be found when it is declared with a Route attribute.

How can this be fixed? Thanks!

Lars
  • 589
  • 2
  • 13
  • 25

0 Answers0