1

I have an URL of the following manner: //...../controller/action?a=1&a=2&a=3&a=4

Is it possible to make controller to convert a into collection of int like in the example below:

public  ActionResult Action(int[] a) {.....}
nemesv
  • 138,284
  • 16
  • 416
  • 359
Andrey Tagaew
  • 1,573
  • 1
  • 15
  • 20
  • 4
    Duplicate of [Action with a string array as parameter](http://stackoverflow.com/questions/4023363/action-with-a-string-array-as-parameter). Make it `?a[]=1&a[]=2...`. – CodeCaster Apr 24 '13 at 10:45
  • Could you tell us the context as we may to give a better solution that way. AKA what the user interface is, why you have this list of `Int`s – Paul C Apr 24 '13 at 10:46

1 Answers1

0

I don't think we can have multiple query string parameters with the same name. Probably has to be //...../controller/action?a=1,2,3,4

public  ActionResult Action(string a) 
{
    var aStrs = a.Split(',');
    var aInts = aStrs.Select(int.Parse).ToList();
}
sunil
  • 5,078
  • 6
  • 28
  • 33