title: RouteValueDictionary/object problem in mvc ActionLink
body: <p>so here it goes:</p>
  
  <p>I have a html helper which renders <code>ActionLink</code>s with the optional parameters of the current url in it. this html  helper also lets you add some more optional parameters as you please and merges them in 1 <code>RouteValueDictionary</code>.</p>
  
  <pre><code>    public static string ActionLinkwParams(this HtmlHelper helper, string linktext, string action, string controller, object extraRVs, object htmlAttributes) {
  
          //get current optional params from current URL
          NameValueCollection c = helper.ViewContext.RequestContext.HttpContext.Request.QueryString;
  
          //put those in a dict
          RouteValueDictionary r = new RouteValueDictionary();
          foreach (string s in c.AllKeys) {
              r.Add(s, c[s]);
          }
  
          RouteValueDictionary htmlAtts = new RouteValueDictionary(htmlAttributes);
  
          RouteValueDictionary extra = new RouteValueDictionary(extraRVs);
  
          //merge them
          RouteValueDictionary m = RouteValues.MergeRouteValues(r, extra);
  
          return helper.ActionLink(linktext, action, controller, m, htmlAtts).ToHtmlString();
      }
  </code></pre>
  
  <p>this works perfect, but I now added SecurityAware Actionlinks.</p>
  
  <p>so </p>
  
  <pre><code>        return helper.ActionLink(linktext, action, controller, m, htmlAtts).ToHtmlString();
  </code></pre>
  
  <p>becomes </p>
  
  <pre><code>        return helper.SecurityTrimmedActionLink(linktext, action, controller, m, htmlAtts);
  </code></pre>
  
  <p>which then calls:</p>
  
  <pre><code>   public static string SecurityTrimmedActionLink(this HtmlHelper htmlHelper, string linkText, string action, string controller, object extraRVs, object htmlAttributes) {
          return SecurityTrimmedActionLink(htmlHelper, linkText, action, controller, extraRVs, htmlAttributes, false);
      }
  
      public static string SecurityTrimmedActionLink(this HtmlHelper htmlHelper, string linkText, string action, string controller, object extraRVs, object htmlAttributes, bool showDisabled) {
          if (controller == null) {
              RouteData routeData = htmlHelper.ViewContext.RouteData;
              controller = routeData.GetRequiredString("controller");
          }
          if (IsAccessibleToUser(action, controller)) {
              return htmlHelper.ActionLink(linkText, action, controller, extraRVs, htmlAttributes).ToHtmlString();
          } else {
              return showDisabled ? String.Format("&lt;span&gt;{0}&lt;/span&gt;", linkText) : "";
          }
      }
  </code></pre>
  
  <p>Now this does NOT work. it compiles, but my URL looks not good.</p>
  
  <pre><code>   &lt;a count="3" keys="System.Collections.Generic.Dictionary`2+KeyCollection[System.String,System.Object]" values="System.Collections.Generic.Dictionary`2+ValueCollection[System.String,System.Object]" href="/2011-2012/Instelling?Count=3&amp;amp;Keys=System.Collections.Generic.Dictionary%602%2BKeyCollection%5BSystem.String%2CSystem.Object%5D&amp;amp;Values=System.Collections.Generic.Dictionary%602%2BValueCollection%5BSystem.String%2CSystem.Object%5D"&gt;Back to List&lt;/a&gt;
  </code></pre>
  
  <p>as you see, what previously did work, now doesnt because it takes the <code>RouteValueDictionary</code>s as objects, which gives me not the result I want. </p>
  
  <p>so I thought, What if i make them <code>RouteValueDictionary</code>s again. </p>
  
  <pre><code>       if (IsAccessibleToUser(action, controller)) {
  
              RouteValueDictionary parsedextraRVs = null;
              if (extraRVs != null &amp;&amp; extraRVs.GetType().Name == "RouteValueDictionary") {
                  parsedextraRVs = (RouteValueDictionary)extraRVs;
              }
  
              RouteValueDictionary parsedHtmlAttributes = null;
              if (htmlAttributes != null &amp;&amp; htmlAttributes.GetType().Name == "RouteValueDictionary") {
                  parsedHtmlAttributes = (RouteValueDictionary)htmlAttributes;
              }
  
  
              return htmlHelper.ActionLink(linkText, action, controller, parsedextraRVs == null ? extraRVs : parsedextraRVs, parsedHtmlAttributes == null ? htmlAttributes : parsedHtmlAttributes).ToHtmlString();
          }
  </code></pre>
  
  <p>but this too gives me the url i just posted above. 
  Why did this work in my <code>ActionLinkwParams</code> method, but not when the <code>ActionLinkwParams</code> calls the <code>SecurityTrimmedActionLink</code> method? and how do I fix this?</p>