title: Can my MVC2 app specify route constraints on Query String parameters?
body: <p>My MVC2 app uses a component that makes subsequent AJAX calls back to the same action, which causes all kinds of unnecessary data access and processing on the server. The component vendor suggests I re-route those subsequent requests to a different action. The subsequent requests differ in that they have a particular query string, and I want to know whether I can put constraints on the query string in my route table.</p>
  
  <p>For example, the initial request comes in with a URL like <a href="http://localhost/document/display/1" rel="nofollow">http://localhost/document/display/1</a>. This can be handled by the default route. I want to write a custom route to handle URLs like <a href="http://localhost/document/display/1?vendorParam1=blah1&amp;script=blah.js" rel="nofollow">http://localhost/document/display/1?vendorParam1=blah1&amp;script=blah.js</a> and <a href="http://localhost/document/display/1?vendorParam2=blah2&amp;script=blah.js" rel="nofollow">http://localhost/document/display/1?vendorParam2=blah2&amp;script=blah.js</a> by detecting "vendor" in the URL.</p>
  
  <p>I tried the following, but it throws a <code>System.ArgumentException: The route URL cannot start with a '/' or '~' character and it cannot contain a '?' character.</code>:</p>
  
  <pre><code>routes.MapRoute(
     null,
     "Document/Display/{id}?{args}",
     new { controller = "OtherController", action = "OtherAction" },
     new RouteValueDictionary { { "args", "vendor" } });
  </code></pre>
  
  <p>Can I write a route that takes the query string into account? If not, do you have any other ideas?</p>
  
  <hr>
  
  <p><strong>Update:</strong> Put simply, can I write routing constraints such that <a href="http://localhost/document/display/1" rel="nofollow">http://localhost/document/display/1</a> is routed to the <code>DocumentController.Display</code> action but <a href="http://localhost/document/display/1?vendorParam1=blah1&amp;script=blah.js" rel="nofollow">http://localhost/document/display/1?vendorParam1=blah1&amp;script=blah.js</a> is routed to the <code>VendorController.Display</code> action? Eventually, I would like any URL whose query string contains "vendor" to be routed to the <code>VendorController.Display</code> action.</p>
  
  <p>I understand the first URL can be handled by the default route, but what about the second? Is it possible to do this at all? After lots of trial and error on my part, it looks like the answer is "No".</p>