This project is read-only.


BeginFormAntiForgeryPost does not change data_ attributes to data- attributes when passed an anonymous htmlAttributes object


Html.BeginFormAntiForgeryPost can be called with an override specifying an object with html attributes to be merged in.

When specifying HTML 5 data attributes, the underscore is usually used in razor and then converted automatically to a hyphen (eg.
@using(Html.BeginFormAntiForgeryPost(Url.Action("Index"), FormMethod.Post, new { data_ajax = "false" }))
<form action="Index" method="post" data-ajax="false">
However, with BeginFormAntiForgeryPost, the underscore is not converted to a hyphen as happens with the built-in MVC HTML Helper methods.

This is because the built-in MVC Html Helpers convert to a RouteValueDictionary via the helper method HtmlHelper.AnonymousObjectToHtmlAttributes which performs this conversion, and Orchard just does the conversion directly.

The attached patch resolves this.

file attachments


sfmskywalker wrote Mar 28, 2014 at 1:28 AM

Fixed in changeset 6f22578f5b2e8d418cf05f3ea3bfee5ea2e9d65e