Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Action with a string array as parameter

I want to call an action with something similar to this uri:

http://server/controller/action/?columns=firstname&columns=lastname&columns=age

and use it like this:

public ActionResult Action(string[] columns)
{

}

how do I do it?

like image 510
jgauffin Avatar asked Oct 26 '10 11:10

jgauffin


People also ask

How do you pass a string array to a parameter in Java?

Passing Array To The Method In Java To pass an array as an argument to a method, you just have to pass the name of the array without square brackets. The method prototype should match to accept the argument of the array type. Given below is the method prototype: void method_name (int [] array);


1 Answers

Google is my friend ;)

http://server/controller/action/?columns[]=firstname&columns[]=lastname&columns[]=age 

Edit:

Actually you just write as I did in my original question. The reason to why I didn't get it working in the first place is that I used "column" in the query string and "columns" in as action parameter.

like image 84
jgauffin Avatar answered Oct 06 '22 18:10

jgauffin