Reputation: 69
I have the following website structure:
(Section/SubSection/Pages/1..n)
e.g.
News/Current
News/Archive
News/Current/Pages/23
News/Archive/Pages/3
If the User goes to /News I want them to default to News/Current, otheriwse they see a page above. Similarly,
Events/Latest
Events/London
Events/Latest/Pages/15
Events/Archive/Pages/4
I've got a controller setup for News and Events but how do I create the Actions and global.asax MapRoutes to handle my structure?
I don't want to use Areas for this, just simple Controllers and Actions please. Each View for a section will handle a ViewModel with a ContentPage property from the database?
So each Section will have a View, that will be populated with a ContentPage PartialView.
Thanks
Upvotes: 0
Views: 148
Reputation: 101150
You got two alternatives:
Archive
and Latest
which makes the section after Pages
a parameter containing the page.Update
The route:
routes.MapRoute(
"MySuperRoute",
"{controller}/{section1}/{section2}/{id}",
new { controller = "Home", action = "TheHandlingAction", id = UrlParameter.Optional }
);
And the action:
public ActionResult TheHandlingAction(string section1, string section2, int id)
{
}
Upvotes: 1