title: getting routes right with asp.net webapi 2
body: <p>I am trying to get my routes to work but end up getting an error.</p>
  
  <p>This is currently my only route:</p>
  
  <pre><code>    config.Routes.MapHttpRoute(
            name: "ActionApi",
            routeTemplate: "api/{controller}/{action}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );
  </code></pre>
  
  <p>I commented this one out as I thought it was the problem</p>
  
  <pre><code>   //config.Routes.MapHttpRoute(
      //    name: "DefaultApi",
      //    routeTemplate: "api/{controller}/{id}",
      //    defaults: new { id = RouteParameter.Optional }
      //);
  </code></pre>
  
  <p>These are the two methods I have :</p>
  
  <pre><code>    public class ProductsController : ApiController
      {
        Product[] products = new Product[] 
        { 
          new Product { Id = 1, Name = "Tomato Soup", Category = "Groceries", Price = 1 }, 
          new Product { Id = 2, Name = "Yo-yo", Category = "Toys", Price = 3.75M }, 
          new Product { Id = 3, Name = "Hammer", Category = "Hardware", Price = 16.99M } 
        };
  
      public IEnumerable&lt;Product&gt; GetAllProducts()
      {
          return products;
      }
  
      [ActionName("GetAllProducts")]
      public IEnumerable&lt;Product&gt; GetAllProductsAction()
      {
          return products;
      }
    }
  </code></pre>
  
  <p>When trying to access it on this URL: <code>http://localhost:27720/api/products/GetAllProducts</code> I get an error: <code>Multiple actions were found that match the request</code></p>
  
  <p>How can that be? I have named one of them with a specific action method. Is this by design or did I configure my routes wrongly?</p>