Hey, one more newbie here, just playing around with .NET MVC. My main task is to have a few semi-static pages on URLs like:
- /about/
- /about/contacts/
- /about/jobs/
I'm using a controller for that called Static and have the following route attached:
routes.MapRoute(
"About",
"about/{id}",
new { controller = "Static", action = "Index", id = UrlParameter.Optional }
);
It seems to work fine as I have the Static controller with the Index method which uses a switch statement to identify which page has to be viewed. I use the RedirectToAction() function to call other actions of the Static controller in order to display pages with other views. My views are:
- /Static/About.aspx
- /Static/Contacts.aspx
- /Static/Jobs.aspx
This method seems to work fine, but what I don't like about it is the redirect, so browsing to /about/contacts I get a redirect to /Static/Contacts which is not what I'd really like to see in the URL.
So my question is - what is the correct way of doing this? And is there a way to explicitly call a certain view from my Index action?
Thanks, ~ K.