Question

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.
}
Was it helpful?

Solution

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("/")) {
        ...
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top