5

Is there any way to pass multiple paramters by using params keyword to an action method with GET as below?

http://.../Method/param1/param2/param3/..../paramN

Action method should be as below:

public ActionResult Method(params string[] parameters)
{
//Do what ever.
}
Halil Ibrahim
  • 1,339
  • 1
  • 20
  • 39

1 Answers1

3

If you need this for url routing you can use something like this:

routes.MapRoute("Name", "param/{*params}", new { controller = ..., action = ... });

ActionResult MyAction(string params) {
    foreach(string param in params.Split("/")) {
        ...
    }
}
AliRıza Adıyahşi
  • 15,658
  • 24
  • 115
  • 197
  • 2
    Is it possible to sent int values to Action(params int[] arr) and then work with int array on server not with strings? – DespeiL Sep 16 '16 at 12:21