title: ASP.NET Core route of a controller and the index action
body: <p>I'm trying to set a route of my controller while also be able to navigate the index without typing <code>Index</code>, here's what I tried:</p>
  
  <p><strong>My route configuration</strong></p>
  
  <pre><code>app.UseMvc(routes =&gt;
          {
              routes.MapRoute(
                  name: "default",
                  template: "{controller=Home}/{action=Index}/{id?}");
          });
  </code></pre>
  
  <p><strong>Try #1</strong></p>
  
  <pre><code>// My controller
  [Route("panel/admin")]
  public class MyController...
  
  // My index action
  public IActionResult Index()...
  </code></pre>
  
  <p>Problem: This doesn't work, all the actions become accessible at <code>panel/admin</code> so I get an error saying <code>Multiple actions matched</code>.<br>
  Even when setting the route of my index action to <code>Route("")</code>, doesn't change anything.</p>
  
  <p><strong>Try #2</strong></p>
  
  <pre><code>// My controller
  [Route("panel/admin/[action]")]
  public class MyController...
  
  // My index action
  [Route("")]
  public IActionResult Index()...
  </code></pre>
  
  <p>Here, the index route doesn't change, it stays <code>panel/admin/Index</code>.</p>
  
  <p><strong>What I want</strong></p>
  
  <p>I want to be able to access my index action when navigating to <code>panel/admin</code> and I also want my other actions to work with just their method names like <code>panel/admin/UsersList</code>.</p>
  
  <p><strong>Complete controller</strong></p>
  
  <pre><code>[Route("panel/admin/[action]")]
  public class MyController
  {
  
      [Route("")]
      public IActionResult Index()
      {
          return View();
      }
  
      public IActionResult UsersList()
      {
          var users = _db.Users.ToList();
          return View(users);
      }
  
      // Other actions like UsersList
  
  }
  </code></pre>
  
  <p>Thank you.</p>