aspnet / AspNetWebStack

ASP.NET MVC 5.x, Web API 2.x, and Web Pages 3.x (not ASP.NET Core)
Other
858 stars 354 forks source link

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

Closed Danthar closed 3 months ago

Danthar commented 3 months ago

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

Danthar commented 3 months ago

For reference. This is the offending code.


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

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.