title: Is it bad to use regex based route constraints?
body: <p>I have the following route that will be hit extensively on my ASP.NET MVC website:</p>
  
  <pre><code>    routes.MapRoute(
          null,
          "products/{ProductID}/{SeoName}",
          new { controller = "Product", action = "ProductDetails", SeoName = UrlParameter.Optional }
      );
  </code></pre>
  
  <p>I want to make sure that the ProductID is a valid integer.  I know I can do this with a regular expression based route constraint or with a custom route constraint that does something like an int.TryParse().</p>
  
  <p>It would seem to me that regular expressions are pretty expensive operations and I don't want to run one for every request that hits my website, but I can't seem to find any information that says I should be careful using regex based route constraints.</p>
  
  <p>So my question is, should I use a regex based route constraint or a custom route constraint to verify that a parameter is an integer?</p>