title: How to overload controller methods with same number of arguments in ASP.NET Core Web API?
body: <p>I'm migrating a full .NET Framework Web API 2 REST project over to ASP.NET Core 2.2 and getting a bit lost in the routing.</p>
  
  <p>In Web API 2 I was able to overload routes with the same number of parameters based on the parameter type, e.g. I could have <code>Customer.Get(int ContactId)</code> and <code>Customer.Get(DateTime includeCustomersCreatedSince)</code> and incoming requests would be routed accordingly.</p>
  
  <p>I haven't been able to achieve the same thing in .NET Core, I either get a 405 error or a 404 and this error instead:</p>
  
  <blockquote>
    <p>"{\"error\":\"The request matched multiple endpoints. Matches: \r\n\r\n[AssemblyName].Controllers.CustomerController.Get ([AssemblyName])\r\n[AssemblyName].Controllers.CustomerController.Get ([AssemblyName])\"}"</p>
  </blockquote>
  
  <p>This was working code in my full .NET framework app Web API 2 app:</p>
  
  <pre><code>[RequireHttps]    
  public class CustomerController : ApiController
  {
      [HttpGet]
      [ResponseType(typeof(CustomerForWeb))]
      public async Task&lt;IHttpActionResult&gt; Get(int contactId)
      {
         // some code
      }
  
      [HttpGet]
      [ResponseType(typeof(List&lt;CustomerForWeb&gt;))]
      public async Task&lt;IHttpActionResult&gt; Get(DateTime includeCustomersCreatedSince)
      {
          // some other code
      }
  }
  </code></pre>
  
  <p>And this is what I converted it to in Core 2.2:</p>
  
  <pre><code>[Produces("application/json")]
  [RequireHttps]
  [Route("api/[controller]")]
  [ApiController]
  public class CustomerController : Controller
  {
      public async Task&lt;ActionResult&lt;CustomerForWeb&gt;&gt; Get([FromQuery] int contactId)
      {
          // some code
      }
  
      public async Task&lt;ActionResult&lt;List&lt;CustomerForWeb&gt;&gt;&gt; Get([FromQuery] DateTime includeCustomersCreatedSince)
      {
          // some code
      }
  }
  </code></pre>
  
  <p>The code above works if I comment out one of <code>Get</code> methods, but fails as soon as I have two <code>Get</code> methods.  I'd expected the <a href="https://docs.microsoft.com/en-us/aspnet/core/web-api/?view=aspnetcore-2.2#binding-source-parameter-inference" rel="nofollow noreferrer"><code>FromQuery</code></a> to use the parameter name in the request to steer the routing, but that doesn't seem to be the case?</p>
  
  <p>Is it possible to overload a controller method like this where you have the same number of parameters and either route based on the parameter's type or the parameter's name?</p>