Reputation: 19646
When using multi-value GET parameters like so:
/?param=1¶m=2¶m=3
You can automatically model-bind to a list, like so:
public ActionResult MyAction(List<int> param)
How can I pass such values using anonymous types, in URL generation?
@Url.Action("MyAction", new { param = ?? })
Using an array / list doesn't work -
@Url.Action("MyAction", new { param = new List<string>{ "1", "2", "3" } })
As it just spits out Object.ToString()
like:
?param=System.Collections.Generic.List%601%5BSystem.String%5D
Cheers
Upvotes: 2
Views: 278
Reputation: 1803
Not the nice solution your after, buy you could do, assuming you know whether to add the ? or not.
@Url.Action("MyAction")[email protected]("¶m=", new [] {1, 2, 3})
Maybe a helper could be written that does this. see URL.Action with a string array?
Upvotes: 1