title: ASP.NET Core Route Attributes - ID and hyphenated slug separated by a hyphen
body: <p>I'm trying to configure the following url structure for one of my controller actions via the Route attribute:</p>
  
  <blockquote>
    <p>/products/12345-purest-green-widgets</p>
  </blockquote>
  
  <p>Here's my route as it stands:</p>
  
  <pre><code>[Route(@"/products/{id:int}-{slug:regex([[\w\-]]+)}")]
  public ContentResult Show(int id, string slug)
  </code></pre>
  
  <p>This doesn't match the intended route, but it does match:</p>
  
  <blockquote>
    <p>/products/12345-purest</p>
  </blockquote>
  
  <p>and also matches with a trailing hyphen after one word, as soon as I add anything else it doesn't match.</p>
  
  <p>Interestingly if I swap out the string literal hyphen (not the regex ones) for a /, it works fine in its entirety:</p>
  
  <pre><code>[Route(@"/products/{id:int}/{slug:regex([[\w\-]]+)}")]
  public ContentResult Show(int id, string slug)
  </code></pre>
  
  <p>successfully matching:</p>
  
  <blockquote>
    <p>/products/12345/purest-green-widgets</p>
  </blockquote>
  
  <p>So it seems to be tripping on the string literal hyphen. Any ideas?</p>