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 is because this is not a web application, it’s a web service that accepts data via the querystring and routes it to a controller that does the work.
So, given a class called MyParam with properties A & B, how can I construct a querystring that will pass data to the following controller method:
public ActionResult MyMethod(List<MyParam> ParamList)
I’ve tried using the MVC framework to RedirectToAction and RedirectToResult to see what it comes up with, but I assume that my n00bness with MVC is causing me to make a mistake because it never passes the data correctly and MyMethod always has null for the parameter.
Thanks in advance!
You may find the following blog post useful for the wire format of lists you need to use if you want the default model binder to successfully parse the request into a strongly typed array of objects. Example of query string:
where:
will successfully bind to: