ASP.NET MVC custom routing sets the default action in each controller

How to determine the route that it refers to by default action.

For instance,

/Customer/acme-company

/Client/bill-johnson

Always look for the Get method in the client and client controllers.

+3
source share
2 answers

Use the default settings.

routes.MapRoute(
    "MyRoute",                                   // Route name
    "{controller}/{someParameter}",              // URL with parameters
    new { controller = "Home", action = "Get" }  // Parameter defaults
);
+8
source

Something like that:

routes.MapRoute("Client",
    "Client/{name}",
    new { controller = "Client", action = "Get", });
0
source

All Articles