title: ASP.NET Core MVC: How to change QueryString param into "pretty" URL param?
body: <p>My issue is an aesthetic one. I have the following Controller:</p>
  
  <pre><code>[HttpGet("[action]/{EmployeeTypeID:int?}")]
  public IActionResult FilterByType(int EmployeeTypeID = 1)
  { ... }
  </code></pre>
  
  <p>Which is called when I go to the following routes, for example: </p>
  
  <pre><code>/Employees/FilterByType
  /Employees/FilterByType/2
  </code></pre>
  
  <p>Great. The controller returns the following ViewModel to the View:</p>
  
  <pre><code>public class EmployeesByTypeViewModel
  {
      public IEnumerable&lt;Employee&gt; FilteredEmployees { get; set; }
      public IEnumerable&lt;SelectListItem&gt; EmployeeTypes { get; set; }
      public int EmployeeTypeID { get; set; }
  }
  </code></pre>
  
  <p>And my view, has a dropdown that <strong>should</strong> change the URL param (in order to filter by a different EmployeeType):</p>
  
  <pre><code>@model Tiendas.Models.EmployeesByTypeViewModel  
  &lt;h2&gt;Employees&lt;/h2&gt;
  &lt;form asp-controller="Employees" asp-action="FilterByType" method="GET"&gt;
      &lt;select asp-for="EmployeeTypeID" asp-items="Model.EmployeeTypes"&gt;
      &lt;/select&gt;
      &lt;button type="submit"&gt;Filter&lt;/button&gt;
  &lt;/form&gt;
  //code displaying filtered employees...
  </code></pre>
  
  <p>However, when I'm at <code>/Employees/FilterByType</code> and I submit the form it results in, for example:</p>
  
  <pre><code>/Employees/FilterByType?EmployeeTypeID=3
  </code></pre>
  
  <p>instead of:</p>
  
  <pre><code>/Employees/FilterByType/3
  </code></pre>
  
  <p>Which is what I want (functionality wise both work). Additionally, if I type the URL above and then submit the form, I get the following:</p>
  
  <pre><code>/Employees/FilterByType/3?EmployeeTypeID=1
  </code></pre>
  
  <p>How can I get a <em>pretty</em> URL param instead of the QueryString? I'm using attribute routing.</p>