Suppose I have an action named "Index" without no parameters in homeController. How we can call the action from url like this "home/index/1/2" ?
Asked
Active
Viewed 212 times
0
-
Possible duplicate of [Routing with Multiple Parameters using ASP.NET MVC](http://stackoverflow.com/questions/2246481/routing-with-multiple-parameters-using-asp-net-mvc) – markpsmith Oct 05 '15 at 14:48
-
In my url can have any number of parameter while action will not have any parameter. So how I can call same action with same action name and varying parameters? e.g. need to call Index action, if we have url "home/Index/test1" or "home/index/test1/test2" – Amita Sharma Oct 05 '15 at 14:58
-
You would need to define multiple routes, or just use query string values – Oct 06 '15 at 01:16
1 Answers
0
If you have a finite number of possibilities, you could have defaulted parameters in your method that can be overridden if necessary...
public ActionResult Index(string arg1 = "", string arg2 = "")
{
}
Look to see if they have values, work from there...

jaredlee.exe
- 81
- 1
- 9