Passing List of objects via querystring to MVC Controller

后端 未结 3 2045
一生所求
一生所求 2021-02-15 14:18

I\'ve got a situation where I need to pass a List of objects to an MVC Controller, but I\'m not sure how to format this in the querystring. The reason I would want to do this i

3条回答
  •  春和景丽
    2021-02-15 15:05

    I've found that the JsonValueProvider works much better than the normal ValueProvider for binding to a list. Simply convert your data to a JSON object like so:

    ?ParamList=[{SomeProperty:'Value'},{SomeProperty:'Value'}];
    

    And the JsonValueProvider will take care of the rest. This is assuming you have the ability to say "post this data as Json".

    I also disclaim whether or not this would be a good idea.

提交回复
热议问题