views:

739

answers:

1

I have the following controller:

public ActionResult Search(string Name, int? Friend, int? Page)

It works if I use this url localhost/users/search/name but these don't localhost/users/search/name/1 and localhost/users/search/name/1/1

+2  A: 

You have to define additional route:

routes.MapRoute(
                "UsersSearch",                                              // Route name
                "users/search/{name}/{friend}/{page}",                           // URL with parameters
                new { controller = "Users", action = "Search" }  // Parameter defaults
            );


routes.MapRoute(
                "UsersSearch",                                              // Route name
                "users/search/{name}/{friend}",                           // URL with parameters
                new { controller = "Users", action = "Search" }  // Parameter defaults
            );
LukLed
So by default it accepts one parameter, and if you want additional parameters you have to map them specifically?
Jhorra
@Jhorra: Yes, that is how it works.
LukLed