Reputation: 2973
I have these classes.
Secion Repository
Section Application
Section Controller
Group Repository
Group Application
Group Controller
Class Repository
Class Application
Class Controller
and all of my controllers have a view named Show
And these structure of entities.
Now the question is this:
I want when I go to the Class
controller I see
Class/Show/class's group's section name/class's group name/class's name
instead of
Class/Show/1
or when I go to the Group controller I see
Group/Show/group's section name/group name
instead of
Group/Show/1
How?
Upvotes: 0
Views: 71
Reputation: 17118
You can define the following route:
routes.MapRoute(
"ShowRoute",
"{controller}/show/{groupsection}/{groupname}/{classname}",
new { controller = "class", action = "show", classname= UrlParameter.Optional },
);
A few things to note:
You can then define your controller methods like this:
public ActionResult Show(string groupsection, string groupname, string classname) {
}
And then have the following requests:
http://your_domain/class/group1-section5/group1/class-obedient
http://your_domain/group/group1-section5/group1/
Upvotes: 1