title: asp.net mvc routing with multiple optional parameters did not work
body: <p>I wrote a attribute route <code>Route("Home/{category?}/{Subcategory?}/List")</code> want to match the following examples
  <code>/Home/C1/S1/List</code>, <code>/Home/C1/List</code>, <code>/Home/List</code></p>
  
  <p>But only to match the first url, the optional parameter did not work.
  How to use a routing rule matches the above three examples?</p>
  
  <pre><code>public class HomeController : Controller
  {
      public IActionResult Index()
      {
          return View();
      }
  
      [Route("Home/{category?}/{subcategory?}/List")]
      public IActionResult List(Category? category = null, SubCategory? subcategory = null)
      {
          return Content(category.ToString() + "/" + subcategory.ToString());
      }
  
      [Route("Home/{code}/Detail")]
      public IActionResult Detail(string code)
      {
          return Content(code);
      }
  }
  
  
  public enum Category
  {
      C1,
      C2,
      C3,
      C4
  }
  
  public enum SubCategory
  {
      S1,
      S2,
      S3,
      S4
  }
  </code></pre>
  
  <p>Similar Questions</p>
  
  <p><a href="https://stackoverflow.com/questions/24678045/routing-optional-parameters-in-asp-net-mvc-5">Routing optional parameters in ASP.NET MVC 5</a></p>
  
  <p><a href="https://stackoverflow.com/questions/35449481/mvc-routing-with-one-fixed-action-and-controllers-with-multiple-optional-paramet">MVC routing with one fixed action and controllers with multiple optional parameters</a></p>