aspnet/AspNetWebStack

TemplateHelpers use the wrong method for translating additionalViewData parameter. causing underscores not to be translated to dashes

Danthar opened this issue · 2 comments

When you use the @Html.Editor or any of its variants of EditorFor anonymous htmlattributes parameters are not translated correctly.

I traced this to the TemplateHelper file. Namely this line of code.

https://github.com/aspnet/AspNetWebStack/blob/main/src/System.Web.Mvc/Html/TemplateHelpers.cs#L308

It uses TypeHelper.ObjectToDictionary(additionalViewData). Which does not translate.

It should be using the System.Web.WebPages.Html.HtmlHelper.AnonymousObjectToHtmlAttributes

For reference.
This is the offending code.


 if (additionalViewData != null)
            {
                foreach (KeyValuePair<string, object> kvp in TypeHelper.ObjectToDictionary(additionalViewData))
                {
                    viewData[kvp.Key] = kvp.Value;
                }
            }
            

Thanks for contacting us.

We're not making any improvements in this area any more as this project is in maintenance mode. Only critical blocking issue with wide impact and security issues are considered.