title: Routing optional parameters with dashes in MVC
body: <p>I've made an routing definition like this:</p>
  
  <pre><code> routes.MapRoute("ProductSearch", "Search-{MainGroup}-{SubGroup}-{ItemType}",
     new {
      controller = "Product",
      action = "Search",
      MainGroup = "", SubGroup = "", ItemWebType = ""});
  </code></pre>
  
  <p>It is not working if the parameters are empty.
  Actually it resolves the url, so Url.Action method resolves the path "Search-12--" but the link is not working, so the GET of the page is not working</p>
  
  <p>With slashes it is working the Url.Action method makes "Search/12"</p>
  
  <pre><code>"Search/{MainGroup}/{SubGroup}/{ItemType}"
  </code></pre>
  
  <p>Is it somehow possible to correct it?</p>
  
  <p>I made a sample with the default mvc project:
  Only added:
  before default route:</p>
  
  <pre><code>    routes.MapRoute(DefaultSearch", "Search-{MainGroup}-{Subgroup}-{ItemType}",
          new {controller = "Home",action = "About", MainGroup = "", 
                Subgroup = "", ItemType = ""});
  </code></pre>
  
  <p>in Home/index.aspx:</p>
  
  <pre><code>&lt;a href="&lt;%=Url.Action("About", "Home", new {maingroup = "2", subgroup = "", itemType = ""}) %&gt;"&gt;
      Search&lt;/a&gt;
  </code></pre>
  
  <p>In HomeController:</p>
  
  <pre><code>public ActionResult About(string maingroup, string subgroup, string itemtype)
  {
    return View();
  }
  </code></pre>
  
  <p>Click on the link and 404</p>