title: Using Html.ActionLink with RouteValues
body: <p>I have the following Html:</p>
  
  <pre><code>&lt;%: Html.ActionLink(item.ProductName, "Details", "Product", new { item.ProductId }, null)%&gt;
  </code></pre>
  
  <p>This is being rendered as:</p>
  
  <pre><code>&lt;a href="/Product/Details?ProductId=1"&gt;My Product Name&lt;/a&gt;
  </code></pre>
  
  <p>However, when I click on this, I get the following error:</p>
  
  <blockquote>
    <p>The parameters dictionary contains a null entry for parameter 'id' of
    non-nullable type 'System.Int32' for method
    'System.Web.Mvc.ActionResult Details(Int32)' in
    'MyProject.Controllers.ProductController'. An optional parameter must
    be a reference type, a nullable type, or be declared as an optional
    parameter. </p>
    
    <p>Parameter name: parameters</p>
  </blockquote>
  
  <p>It appears that my routing doesn't like the "?ProductId=1" query string.</p>
  
  <p>If I use instead:</p>
  
  <pre><code>&lt;%: Html.ActionLink(item.ProductName, string.Format("Details/{0}", item.ProductId), "Product", null, null)%&gt;
  </code></pre>
  
  <p>I get the following link rendered:</p>
  
  <pre><code>&lt;a href="/Product/Details/1"&gt;My Product Name&lt;/a&gt;
  </code></pre>
  
  <p>...and this works correctly when clicked.</p>
  
  <p>Am I missing something basic here?  I'd like to use RouteValues, but I don't understand why this error is being thrown.  How can I get my Controller method to accept query string parameters?</p>
  
  <p>The only route mapping I have is:</p>
  
  <pre><code>    routes.MapRoute(
          "Default", // Route name
          "{controller}/{action}/{id}", // URL with parameters
          new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
      );
  </code></pre>