URL.Action with a string array?

asp.net-mvc asp.net-mvc-3 c# entity-framework razor

Question

I have an array of strings that I need to pass in a query string of Url.Action.

Url.Action("Index", "Resource", new { FormatIds = Model.FormatIDs})

Right now the link is showing up in my browser as System.String[] instead of a query string. Is it possible to have MVC do this automatically with model binding?

I need it to bind with my controller action like:

public ActionResult Index(string[] formatIDs)
1
11
12/14/2012 11:22:09 PM

Popular Answer

To get the list of string to automatically bind using the default binder, you will need to provide them as:

name=value&name=value2&name=value3

So you'll need to convert your list to something like:

Index?formatIDs=1&formatIDs=2&formatIDs=3
10
12/15/2012 1:05:14 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow