Overriding MVC DefaultModelBinder to handle arrays of complex objects

自古美人都是妖i 提交于 2019-12-11 10:21:36

问题


The default MVC model binder (System.Web.Mvc.DefaultModelBiner) correctly binds the following syntax of nested arrays:

 array[0].propertyA=valueA&array[0].propertyB=valueB& ...etc

To the following action method:

 public ActionResult AjaxHandler(Part[] array, ...)

However, jQuery.param() is only able to serialize into the following syntax :

 array[0][propertyA]=valueA&array[0][propertyB]=valueB& ...etc

Setting traditional flag to true still produces incorrect mapping:

array=[object+Object]&...etc

I was checking out DefaultModelBinder.cs but that class is something like 900 lines of code and would take quite some time to dissect.

I'm looking for some pointers on which members to override or an implementation would be even more appreciated.

来源:https://stackoverflow.com/questions/17558735/overriding-mvc-defaultmodelbinder-to-handle-arrays-of-complex-objects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!