title: ASP.NET MVC Passing Lists to RouteData QueryString
body: <p>The recommended approach for passing lists of values as a QueryString is </p>
  
  <pre><code>www.site.com/search?value=1&amp;value=2&amp;value=3&amp;value=4
  </code></pre>
  
  <p>ASP.NET handles this well:</p>
  
  <pre><code>string value = QueryString.Get("value"); // returns "1,2,3,4"
  </code></pre>
  
  <p>But I can't figure out a way of passing these values by into RouteData.  The obvious approach would be to add</p>
  
  <pre><code>int[] value = {1,2,3,4};
  </code></pre>
  
  <p>into the RouteData and have super smart MVC sort things out for me.  Unfortunately MVC is dump when it comes to passing arrays into RouteData, it basically calls .ToString() adding value=int[] to my QueryString.</p>
  
  <p>I tried adding the values to RouteValueDictionary (but being a dictionary can't handle this:)</p>
  
  <pre><code>RouteValueDictionary dict = new RouteValueDictionary();
  dict.Add("value","1");
  dict.Add("value","2"); // Throws Exception (Keys must be unique)
  </code></pre>
  
  <p>I could try passing values like this:</p>
  
  <pre><code>www.site.com/search?value=1,2,3,4
  </code></pre>
  
  <p>but this is Encoded to the URL as</p>
  
  <pre><code>www.site.com/search?value=1%2C2%2C3%2C4
  </code></pre>
  
  <p>I'm not sure if this is a bad thing or not,but it sure looks bad.</p>
  
  <p>So, how do you pass lists of values as RouteData in ASP.NET MVC.  Is there any way I can add to MVC to make it handle an int[]?  Or is the underlying Dictionary-based data structure a show-stopper for passing lists of values easily to ASP.NET MVC?</p>