title: Why the query strings in my ASP.NET MVC route?
body: <p>On an ASP.NET MVC (Beta) site that I am developing sometimes calls to ActionLink will return to me URLs containing querying strings. I have isolated the circumstances that produce this behavior, but I still do not understand why, instead of producing a clean URL, it decides to using a query string parameter. I know that functionally they are the same, but for consistency (and appearance) of the URLs this is not what I want. </p>
  
  <p>Here are my routes:</p>
  
  <pre><code>routes.MapRoute(
      "Photo Gallery Shortcut",
      "group/{groupname}",
      new { controller = "Photos", action = "All", Id = "" });
  
  routes.MapRoute(
      "Tagged Photos", //since the Tagged action takes an extra parameter, put it first
      "group/{groupname}/Photos/Tagged/{tagname}/{sortby}",
      new { controller = "Photos", action = "Tagged", Id = "", SortBy = "" });
  
  routes.MapRoute(
      "Photo Gallery", //since the Gallery's defualt action is "All" not "Index" its listed seperatly
      "group/{groupname}/Photos/{action}/{sortby}",
      new { controller = "Photos", action = "All", Id = "", SortBy = "" });
  
  routes.MapRoute(
      "Group",  //&lt;-- "Group" Category defined above
      "group/{groupname}/{controller}/{action}/{id}",
      new {controller = "Photos", action = "Index", Id = ""});
  </code></pre>
  
  <p>Now the problem only occurs when I am looking at the view described by the route named "Tagged Photos" and execute ActionLink via:</p>
  
  <pre><code>Html.ActionLink&lt;PhotosController&gt;(p =&gt; p.All((string)ViewData["group"], ""), "Home")
  </code></pre>
  
  <p>Which produces the URL:</p>
  
  <pre><code>http://domain/group/GROUPNAME?sortBy=
  </code></pre>
  
  <p>From any other view the URL produced is:</p>
  
  <pre><code>http://domain/group/GROUPNAME
  </code></pre>
  
  <p>I have pulled down Phil's <a href="http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx" rel="nofollow noreferrer">ASP.NET Routing Debugger</a>, and everything appears in order. This one has me stumped. Any ideas?</p>