title: Handle multiple endpoints in .NET Core 3.1 Web API by Query Params
body: <p>I am migrating controllers from .NET Framework to .NET Core and I want to be compatibility with API calls from previous version. I have problem with handling multiple routes from Query Params.</p>
  <p>My example controller:</p>
  <pre><code>[Route(&quot;/api/[controller]&quot;)]
  [Route(&quot;/api/[controller]/[action]&quot;)]
  public class StaticFileController : ControllerBase
  {
      [HttpGet(&quot;{name}&quot;)]
      public HttpResponseMessage GetByName(string name)
      {
      }
  
      [HttpGet]
      public IActionResult Get()
      {
      }
  }
  </code></pre>
  <p>Calling <code>api/StaticFile?name=someFunnyName</code> will lead me to <code>Get()</code> action <strong>instead of expected</strong> <code>GetByName(string name)</code>.</p>
  <p>What I want to achieve:</p>
  <ul>
  <li>Calling GET <code>api/StaticFile</code> -&gt; goes to <code>Get()</code> action</li>
  <li>Calling GET
  <code>api/StaticFile?name=someFunnyName</code> -&gt; goes to <code>GetByName()</code> action</li>
  </ul>
  <p>My <code>app.UseEndpoints()</code> from <code>Startup.cs</code> have only these lines:</p>
  <pre><code>endpoints.MapControllers();
  endpoints.MapDefaultControllerRoute();
  </code></pre>
  <p>If I use <code>[HttpGet]</code> everywhere and add <code>([FromQuery] string name)</code> it gets me <code>AmbiguousMatchException: The request matched multiple endpoints</code></p>
  <p>Thank you for your time to helping me (and maybe others)</p>