title: Correctly making an ActionLink extension with htmlAttributes
body: <p>I use a custom extension for my ActionLinks. I have added an attribute <code>data_url</code> which is meant to be translated to an attribute of <code>data-url</code>. This is, replacing the underscaore with a dash.</p>
  
  <p>Here is link 1 using my custom extension: </p>
  
  <pre><code>@Ajax.ActionLink("Add", MyRoutes.GetAdd(), new AjaxOptions()
      , new { data_url = Url.Action(...)})
  </code></pre>
  
  <p>Result: <code>data_url</code></p>
  
  <p>Here is link 2 using the framework ActionLink:</p>
  
  <pre><code>@Ajax.ActionLink("Add 2", "x", "x", null, new AjaxOptions()
      , new { data_url = Url.Action(...) })
  </code></pre>
  
  <p>Result: <code>data-url</code></p>
  
  <p>Here is the extension, simple enough, <strong>except that the only way to pass the htmlAttributes through that I know of is by using the <code>ToDictionaryR()</code> extension. I suspect this is the problem, so I am wondering if I should be using something else.</strong> I have supplied that extension below too.</p>
  
  <pre><code>public static MvcHtmlString ActionLink(this AjaxHelper helper, string linkText
          , RouteValueDictionary routeValues, AjaxOptions ajaxOptions
          , object htmlAttributes = null)
  {
      return helper.ActionLink(linkText, routeValues["Action"].ToString()
          , routeValues["Controller"].ToString(), routeValues, ajaxOptions
          , (htmlAttributes == null ? null : htmlAttributes.ToDictionaryR()));
  }
  
  public static IDictionary&lt;string, object&gt; ToDictionaryR(this object obj)
  {
      return TurnObjectIntoDictionary(obj);
  }
  public static IDictionary&lt;string, object&gt; TurnObjectIntoDictionary(object data)
  {
      var attr = BindingFlags.Public | BindingFlags.Instance;
      var dict = new Dictionary&lt;string, object&gt;();
      foreach (var property in data.GetType().GetProperties(attr))
      {
          if (property.CanRead)
          {
              dict.Add(property.Name, property.GetValue(data, null));
          }
      }
      return dict;
  }
  </code></pre>
  
  <p>thank you</p>