2

I'm using mvc3 to build a simple site with 5 static pages. I'm just wondering what the best practice is in this situation. So far I have only one 'Page' Controller which has 5 functions, each returning the appropriate view.

I've also updated the global.asax file to use:

routes.MapRouteLowercase(
    "Default", // Route name
    "{action}/{id}", // URL with parameters
    new { controller = "Page", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

I realise that the general rule is use one controller for each logical unit so I figure this works out okay for a small site?

Is this a suitable approach or should I do it differently?

Thanks.

1
  • I wouldn't recommend MVC, If you are going for static pages, simply use .html files as Jakub mentioned. Commented Apr 30, 2012 at 11:52

1 Answer 1

2

Your approach is fine.

However, if you have just static pages, why do you use MVC at all? You can just deploy a bunch of .html files and be done with it.

Sign up to request clarification or add additional context in comments.

3 Comments

Also, you can use routing as well even without asp.net mvc. routes.MapPageRoute will allow you to create a url which doesn't exactly match the path on disk (although going to the path on disk will work as well).
Thanks Jakub. I was going to build the site just as static html pages but I wanted to have the option to provide friendly urls without having to tamper with IIS :-)
Sorry Andy, how do I use routes.MapPageRoute with static pages?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.