In my limited (2 weeks) experience in asp.net MVC3, for most action methods, I have never needed to add a route registration. But I have noticed that if the action method has an input parameter, then I can’t access the method with a url of the form http://www.mysite.com/myController/myAction/myParameter1/myParameter2/myParameter3 (without the ? mark ) unless I map the route. Is that how its supposed to be?
Share
By default, you already have registered route:
it accepts one parameter, named id, so your action:
will “catch” the request:
and
idwill get value “parameter_value”.If you need more than one parameter (or parameter has to be names something else than “id”), then you have to register new route.
In case when you have 2 parameters, you will register route like this:
and your action might be: