title: Different URL's to the same controller ASP MVC Core
body: <p>I need to generate a navigation that has 'System' and 'Category' archons or buttons. System and Category are using the same controller. I would like to use <code>[Route()]</code> instead of the <code>Startup</code> file for routing.</p>
  
  <p>For category archon works great:</p>
  
  <pre><code>&lt;a asp-area="Admin" asp-controller="@value.Controller" asp-action="@Constants.Route.List" asp-route-valueId="@value.ValueId"&gt;@value.Value&lt;/a&gt;
  </code></pre>
  
  <p>but I dont kow how to use the same controller for 'admin/system/list' instead of admin/categorytype/list, so far I tried:</p>
  
  <p><strong>1)</strong></p>
  
  <pre><code>&lt;a asp-area="Admin" asp-route="System" asp-action="@Constants.Route.List" asp-route-valueId="@value.ValueId"&gt;@value.Value&lt;/a&gt;
  </code></pre>
  
  <p><strong>2)</strong></p>
  
  <pre><code>&lt;a asp-route="Admin/System/List" asp-route-valueId="@value.ValueId"&gt;@value.Value&lt;/a&gt;
  </code></pre>
  
  <p><strong>and at controller</strong></p>
  
  <pre><code>[Area("Admin")]
  [Route("Admin/[controller]")]
  [Route("Admin/System")]
  [Authorize]
  public class CategoryTypeController : Controller {}
      [Route("[action]")]
      public ViewResult List(int valueId) {}
  </code></pre>
  
  <p><strong>3)</strong></p>
  
  <pre><code>&lt;a href="@Url.RouteUrl("SystemValue", new { valueId = value.ValueId })"&gt;@value.Value&lt;/a&gt;
  </code></pre>
  
  <p><strong>and at controller</strong></p>
  
  <pre><code>[Area("Admin")]
  [Route("Admin/[controller]")]
  [Route("Admin/System", Name = "SystemValue")]
  [Authorize]
  public class CategoryTypeController : Controller {}
      [Route("[action]")]
      public ViewResult List(int valueId) {}
  </code></pre>
  
  <p>none of the above routes generated url that allow me to go to the CategoryType controller and List action by /admin/system/list</p>
  
  <p>I also have <code>app.UseMvcWithDefaultRoute();</code> at <code>Startup</code> file.</p>
  
  <p><strong>Edit:</strong>
  When I enter the address manually <code>/admin/system/list</code> - the router works,
  but I can't generate such a url for button or archon to match <code>/admin/system/list</code></p>
  
  <p>as in the attached picture, the archon does not have any url
  <a href="https://i.stack.imgur.com/1t4L5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1t4L5.png" alt="screenshot of the browser"></a></p>
  
  <p><s>
  <strong>EDIT:</strong>
  I found a solution, but I'm not happy with it, it turns out that I do not understand how routing works. For me, the <code>[Route ()]</code> attribute is one way to define routs and <code>app.UseMvc()</code> is the second way. I had to define routes in two places.</p>
  
  <p>at <strong>Startup.cs</strong></p>
  
  <pre><code>    app.UseMvc(routes =&gt;
      {
          routes.MapRoute(
              name: "SystemValue",
              template: "Admin/System/List/{id?}",
              defaults: new { area = "Admin", controller = "CategoryType", action = "List" });
      });
  </code></pre>
  
  <p><strong>controller</strong></p>
  
  <pre><code>[Area("Admin")]
  [Route("Admin/[controller]")]
  [Route("Admin/System", Name = "SystemValue")]
  [Authorize]
  public class CategoryTypeController : Controller
  {}
      [Route("[action]")]
      public ViewResult List(int valueId) {}
  </code></pre>
  
  <p><strong>view</strong></p>
  
  <pre><code>&lt;a href="@Url.RouteUrl("SystemValue", new { valueId = value.ValueId})"&gt;@value.Value&lt;/a&gt;
  </code></pre>
  
  <p>I will still be looking for a solution how to do it using only <code>[Route ("")]</code>
  </s></p>