Answer the question
In order to leave comments, you need to log in
How to implement routing in the form of domain.com/users and domain.com/user/123?
Hello, I hope that someone will tell you the solution to this problem.
There is a UsersController controller, with Index() and User(int id) methods, at the moment the routing is configured as follows:
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new[] { "Proj.Controllers" }
);
Answer the question
In order to leave comments, you need to log in
routes.MapRoute(
"UsersGeneric",
"{action}/{id}",
new {
controller = "Users",
action = "User",
id = UrlParameter.Optional
},
new[] { controller = "Users", [email protected]"\d+" },
new[] { "Proj.Controllers" }
);
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new {
controller = "Home",
action = "Index",
id = UrlParameter.Optional
},
new[] { "Proj.Controllers" }
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question