title: Can't map route to action, ASP.NET Core Web API
body: <p>I am working on Web API project and have the following problem:</p>
  
  <p>I have tried to call the action method called 'GetUserBy' with the following Url (<a href="https://localhost:44328/api/Users/GetUserBy?username=myusername&amp;password=mypassword" rel="nofollow noreferrer">https://localhost:44328/api/Users/GetUserBy?username=myusername&amp;password=mypassword</a>), but the result I received in the browser looks like this:</p>
  
  <pre><code>{"id":["The value 'GetUserBy' is not valid."]}
  </code></pre>
  
  <p>Below is my UsersController:</p>
  
  <pre><code>[Route("api/[controller]")]
  [ApiController]
  public class UsersController : ControllerBase
  {
  
      // GET: api/Users
      [HttpGet]
      public IEnumerable&lt;User&gt; GetUsers()
      {
          //this works
          //code removed for simplicity
      }
  
      //GET: api/Users/5
      [HttpGet("{id}")]
      public async Task&lt;IActionResult&gt; GetUser([FromRoute] int id)
      {
         //this works too
      }
  
      [HttpGet("Users/GetUserBy")]
      public async Task&lt;IActionResult&gt; GetUserBy([FromQuery]string username, [FromQuery]string password)
      {
          //this doesn't work
      }
  }
  </code></pre>
  
  <p>when I insert the breakpoint on this method, code execution never seems to come there regardless I call it or not.</p>
  
  <p>I added the following code in startup.cs file, but nothing has changed.</p>
  
  <pre><code> app.UseMvc(
              routes =&gt;
              {
                  routes.MapRoute("GetUserBy", "{controller=Users}/{action=GetUserBy}");
              }
              );
  </code></pre>
  
  <p>I have also visited the following web page, but I can't find the answer.
  <a href="https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/routing?view=aspnetcore-2.1" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/routing?view=aspnetcore-2.1</a></p>