Frage

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.
}
War es hilfreich?

Lösung

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("/")) {
        ...
    }
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top