I have web api 2 controller actions:
[HttpGet] public Response<IEnumerable<Product>> Get() { ....(Get all products) } [HttpGet] public Response<Product> Get(int id) { ....(Get product by id) } [HttpGet] public Response<IEnumerable<Product>> Category(int id) { .... (Get products by category) } I want to use this controllers with url:
http://localhost/api/product http://localhost/api/product/1 http://localhost/api/product/category/1 But this url http://localhost/api/product/1 returns error,
Multiple actions were found that match the request
My config settings are like this:
config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); config.Routes.MapHttpRoute( name: "DefaultApiWithAction", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional } );