title: Html.ActionLink extension
body: <p>I am trying to extend the Html.ActionLink as I want to add a custom meta data for a shared component (in this case a modal). </p>
  
  <p>My aim is to further extend the LinkExtensions class within .Net MVC which will add a value to the html class attribute and add a custom data attribute resulting in the following:</p>
  
  <pre><code>&lt;a href="/Controller/Action/id" class="show-in-modal style1 style2" data-title="Modal title"&gt;Link&lt;/a&gt;
  </code></pre>
  
  <p>The helper will look similar to the MVC method:</p>
  
  <pre><code>public static MvcHtmlString ModalLink(this HtmlHelper htmlHelper, string title, string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes)
  {
      // Add 'show-in-modal' class here
      // Add 'data-title' attribute here
  
      return htmlHelper.ActionLink(linkText, actionName, controllerName, routeValues, htmlAttributes);
  }
  
  @Html.ModalLink("Modal title", "Link", "action", "controller", new { id = "id" }, new { @class = "style1 style2" });
  </code></pre>
  
  <p>This issue I am having is I cannot easily modify the htmlAttributes object to add my class name and data attribute, which makes sense as this is a read only anonymous object.</p>
  
  <p>Is there a way I can easily apply the required values/meta data without having to rip everything apart with reflection and put back together again?</p>
  
  <p>I noticed MVC has overloads which accepts html attributes in the form of an <code>IDictionary&lt;string, object&gt;</code>, is there an extension method which converts anonymous types to a modifiable dictionary?</p>
  
  <p>All i get within searching is how to use the Html.ActionLink() method.</p>