title: Pass Dictionary of routeValues to ActionLink
body: <p>All,</p>
  
  <p>Getting to grips with ASP.NET MVC. So far, so good, but this one is a little nuts.</p>
  
  <p>I have a view model that contains a dictionary of attributes for a hyperlink, used like this:</p>
  
  <p>menu = model variable</p>
  
  <pre><code>Html.ActionLink(Html.Encode(menu.Name), Html.Encode(menu.Action), Html.Encode(menu.Controller), menu.Attributes, null)
  </code></pre>
  
  <p>The problem is the position of "menu.Attributes" expects an object in the form:</p>
  
  <pre><code>new  { Name = "Fred", Age=24 }
  </code></pre>
  
  <p>From what I can tell, this anonymous object is actually converted to a dictionary via reflection anyway BUT you can't pass a dictionary to it in the first place!!!</p>
  
  <p>The Html generated for the link simply shows the dictionary type.</p>
  
  <p>How on earth do I get round this? The whole point is that its general and the controller can have set the menu.Attributes previously....</p>
  
  <p>Based on a post below I tried the following:</p>
  
  <pre><code>Html.ActionLink(Html.Encode(menu.Name), Html.Encode(menu.Action), Html.Encode(menu.Controller), new RouteValueDictionary(menu.Attributes), new Dictionary&lt;string,object&gt;())
  </code></pre>
  
  <p>but this still doesn't work (I guess the code internally calls the generic method that takes objects?). The above (and my original solution of passing a dictionary to the 4th paramater produces a HTML similar to this:</p>
  
  <pre><code>&lt;a href="/EditRole?Comparer=System.Collections.Generic.GenericEqualityComparer%601%5BSystem.String%5D&amp;amp;Count=1&amp;amp;Keys=System.Collections.Generic.Dictionary%602%2BKeyCollection%5BSystem.String%2CSystem.String%5D&amp;amp;Values=System.Collections.Generic.Dictionary%602%2BValueCollection%5BSystem.String%2CSystem.String%5D"&gt;EditDocumentRoles&lt;/a&gt;
  </code></pre>
  
  <p>i.e. it's using reflection and working things out completely wrong...</p>