Sending a JSON array to be received as a Dictionary

后端 未结 2 517
别那么骄傲
别那么骄傲 2020-12-17 02:04

I have a method with the following signature:

public ActionResult RenderFamilyTree(string name, Dictionary children)

2条回答
  •  离开以前
    2020-12-17 02:58

    The default model binder supports advanced scenarios such as binding to lists and dictionaries. In order for this to work you need to send the following request:

    children[0].Key=key1&children[0].Value=value1&
    children[1].Key=key2&children[1].Value=value2&
    name=Raul
    

    So you could either write your own custom binder or format your query parameters in this way. I am not sure that jQuery supports this out of the box.

提交回复
热议问题