title: In ASP.NET MVC, how can I match URLs to a route if an URL segment contains literal dashes and one of the parameter constraints allows dashes?
body: <p>Given this route:</p>
  
  <pre><code>{prefix}-{id}-{postfix}
  </code></pre>
  
  <p>There is one URL segment, and 3 so-called parameters: <code>prefix</code>, <code>id</code> and <code>postfix</code>. Any URL with 3 dashes will generally match this route (if the parameter values match the constraints defined for those parameters). However, as soon as I define, for the 3rd parameters, a regex constraint that allows dashes, the entire route no longer matches.</p>
  
  <p>For example:</p>
  
  <pre><code>routes.MapRoute(
      url: "{prefix}-{id}-{postfix}", 
      constraints: new {
          prefix: "test",
          id: "42"
          postfix: "[a-z-]+"
      }
  );
  </code></pre>
  
  <p>This will <strong>not</strong> match a request to ~/test-42-hello-world/</p>
  
  <p>And by that I mean that the ASP.NET routing engine does not even consider this route for this URL. I know that because I replaced one of the constraints with a custom <code>IRouteConstraint</code> and put a breakpoint inside its <code>Match()</code> method, and my breakpoint was never hit.</p>
  
  <p>I would like to know if what I want to do is possible.</p>
  
  <p>If not, I would really appreciate a link to some documentation (or source) that I can look at to understand the reason this doesn't work.</p>