I'm using WebApi and attribute routing.
I have a customer controller that has a method to get all the animals for that customer. This method & route work great. However, I also want a method that just returns a list of all the customers, and I can't get that one to work.
Here is my controller:
[RoutePrefix("api/customer")]
public class CustomerController : ApiController
{
[HttpGet("{customerId}/animals")]
public PagedHorse Get(int customerId)
{
Console.WriteLine("Get");
}
[HttpGet("")]
public PagedCustomer List()
{
Console.WriteLine("List");
}
}
If I change the List route to be "{customerId}/List"
and ignore the parameter passed in, it works. What am I doing wrong with these routes? I'd really like to just have api/customer
return a list of all customers.