Overriding MVC DefaultModelBinder to handle arrays

2019-07-28 03:04发布

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.

0条回答
登录 后发表回答