0

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.

taylonr
  • 10,732
  • 5
  • 37
  • 66
  • This is a straight forward scenario that should have worked. I tried it myself and wasn't able to repro the issue you mentioned. What is the response that you are seeing? – Kiran Sep 22 '13 at 22:27
  • I'm getting a 404. But I'm using Hot Towel SPA, and realized it does some things with it's routing, so I'm going to check that out and see if there is some interference. – taylonr Sep 22 '13 at 22:57

1 Answers1

0

It appears there was some amount of interference between the Hot Towel SPA project type and my project. I didn't start from scratch with Hot Towel, but added it to an existing project, so I believe there were some routing issues.

I deleted the HotTowel specific Configs (e.g. HotTowelRouteConfig) because everything that was done there I was already doing in my ASAX file.

After that everything worked fine.

taylonr
  • 10,732
  • 5
  • 37
  • 66