Aran Mulholland
Aran Mulholland

Reputation: 23945

ASP.NET MVC Routing with multiple optional parameters

I have a situation on a single page web application. I use address information on the client to determine what data to load. I would like to be able to have url's like the following all direct to the Index action method on the HomeController.

http://mysite.com/Home/Index/Value/23/Another/34
http://mysite.com/Home/Index/Value/23/Another/34/StillAnother/45

In that controller method I would like a list of parameters such as:

{"Value", "23", "Another", "34"}
{"Value", "23", "Another", "34", "StillAnother", "45"}

Is this possible?

Upvotes: 1

Views: 4294

Answers (1)

Timothy Strimple
Timothy Strimple

Reputation: 23070

A single page web application doesn't mean having a single Controller and Action so I hope that's not what you're after. If you're just trying to bind additional URL parameters, then it is easily accomplished using routing. Take a look at this question: Infinite URL Parameters for ASP.NET MVC Route

Upvotes: 2

Related Questions