I need to be able to write a list in an URL that is mapped to a controller which then does something on the list. As an example:
i go to
http://localhost:8080/API/ControllerID/Action/a,b,c,d
which i would like to parse to a controller that looks like:
public ActionResult Action(List<string> ListItems)
{
// do something on the list
}
And the maproute looking somthing like this:
context.MapRoute(
"ListActions",
"API/{controller}/{action}/{ListItems}",
new { controller = "", action = "", ListItems = ""}
);
Is this possible?
Yes, possible. Use different delimeter, e.g. “-“, whatever doesn’t break logic.
in controller you can split string via String.Split.