title: Asp.Net MVC Routing - how do I match the whole URL?
body: <p>I'm trying to create a catch-all route to track when an affiliate string is in the URL. An affilite code is marked by an <code>x</code> followed by an <code>int</code>, and will only appear at the end of a URL (but before the query string).</p>
  
  <p>The idea is that I will extract the affiliate ID, do some logging, then do a 301 to the same request without the affiliate ID. </p>
  
  <p>For example: </p>
  
  <pre><code>http://www.domain.com/x32
  http://www.domain.com/x32/
  http://www.domain.com/path/to/something/x32
  http://www.domain.com/x32?query=string
  http://www.domain.com/x32/?query=string
  http://www.domain.com/path/to/something/x32?query=string
  http://www.domain.com/path/to/something/x32/?query=string
  </code></pre>
  
  <p>I have this route</p>
  
  <pre><code>routes.Add(new Route("{url}/x{affiliateExternalId}", new MvcRouteHandler())
  {
       Defaults = new RouteValueDictionary(
        new { controller = "Home", action = "LogCookieAndRedirect" }
       ),
       Constraints = new RouteValueDictionary(new { affiliateExternalId = @"\d{1,6}" })
  });
  </code></pre>
  
  <p>Which only matches </p>
  
  <pre><code>http://www.domain.com/path/x32
  http://www.domain.com/path/x32/
  </code></pre>
  
  <p>What do I need to do to match everything and pass the query string to the controller? There is a <code>*</code> operator that I suspect I should use, but I can't get it to do what I need. </p>