title: How to work with ASP.Net WebApi overloaded methods?
body: <p>I have a situation where I have two methods one accepts a poco and another list of poco in my controller class:</p>
  
  <pre><code>[AcceptVerbs("PUT")]
  [ActionName("Item")]
  public void SaveItem([FromBody] Item item)
  {
      m_controller.SaveItem(item);           
  }
  
  [AcceptVerbs("PUT")]
  [ActionName("Items")]
  public void SaveItems([FromBody] List&lt;Item&gt; items)
  {
      m_controller.SaveItem(items);
  }
  </code></pre>
  
  <p>my routing table looks something like:</p>
  
  <pre><code>routes.MapHttpRoute("Item Route",
                      "api/item/{orderId}",
                      new
                      {
                          controller = "MyOrder",
                          action = "Item",
                          orderId = RouteParameter.Optional
                      });
  
  routes.MapHttpRoute("Items Route",
                      "api/items/{orderId}",
                      new
                      {
                          controller = "MyOrder",
                          action = "Items",
                          orderId = RouteParameter.Optional
                      });
  </code></pre>
  
  <p>This works as expected. But I thought of refactoring the code to try overloading. I tried to overload the methods in my controller and have just one route but it failed with 500 error - Invalid Request. I thought webapi will resolve the call by verifying the parameter - if it is a list then it will call the overloaded method with list as parameter otherwise the other method. I was planning to do something like:</p>
  
  <pre><code>[AcceptVerbs("PUT")]
  [ActionName("Item")]
  public void SaveItem([FromBody] Item item)
  {
      m_controller.SaveItem(item);           
  }
  
  [AcceptVerbs("PUT")]
  [ActionName("Item")]
  public void SaveItem([FromBody] List&lt;Item&gt; items)
  {
      m_controller.SaveItem(items);
  }
  </code></pre>
  
  <p>my routing table looks something like:</p>
  
  <pre><code>routes.MapHttpRoute("Item Route",
                      "api/item/{orderId}",
                      new
                      {
                          controller = "MyOrder",
                          action = "Item",
                          orderId = RouteParameter.Optional
                      });
  </code></pre>