1

I am creating an MVC 4 web app written in C#. Among other functionality, one feature should allow a user to navigate to a page like this:

/pagecontroller/some-specific-page-name

Or, alternately,

/pagecontroller/12345

The contents of these pages are largely static html. It rarely changes.

I'll be the only one adding new pages, and I'm happy whether I do it in html or via a CMS.

What method of storing and handling this sort of content is suggested?

Should I store the html in the database and deliver it that way? I certainly want some page-specific information in the database (e.g. page categories, etc) but putting a hunk of html in the database doesn't seem right to me. Alternately I could create a database that has article names corresponding to static html documents that could be plucked out via ajax. The styling will not take place on these pages, so I see no issues there. Still, as articles build up that didn't feel 100% right either. A third, rather silly idea, is a table called elements. Each row would contain one or more elements and the code could, using a sort of template, place the elements where desired.

The real trick is I want this to be able to scale well from a small project to a larger one as needed.

I'm not using webkit.

How do you suggest I go about this? Thanks very much.

EDIT: I should say - none of these pages contain any forms or need much in the way of server-side might.

5
  • 1
    deliveron.com/blog/post/… pretty good guide. Commented Mar 19, 2013 at 18:10
  • Thanks for the link. I'm familiar with this sort of thing. I'm probably not explaining myself very well. I guess you could compare what I'm doing to a magazine, and each page being an article. The articles don't change over time. They don't need to be database-dynamic. Does that make sense? I can do it (in the large paragraph above I throw out a few possible ways of accomplishing it) but I wanted to know what others thought was the best way to handle a ton of pages (or, for ease of understanding, articles). Commented Mar 19, 2013 at 18:23
  • Actually writing the controller and passing information into it is the easy part. I'm trying to determine how best to store and deliver the html pages (articles, if you like) Commented Mar 19, 2013 at 18:23
  • 1
    Why not just store your pages on disk as regular HTML files and have a controller action that returns them by name? Commented Mar 19, 2013 at 19:04
  • Good suggestion ilia g - thanks. I may go that route. Commented Mar 19, 2013 at 19:37

2 Answers 2

2

Alternatively, you can override mvchandler and do something like this:

https://github.com/noogen/phuncms/blob/master/src/Phun/Routing/PhunMvcRouteHandler.cs

Or you can write your own module and set it up in the web.config, similar to stackoverflow implementation:

http://samsaffron.com/archive/2011/10/13/optimising-asp-net-mvc3-routing

See example on phuncms azure demo which has link to some static file.

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

Comments

1

I believe if I understand your delima, you could use the HandleUnknownAction functionality that mvc controllers provide.

You could essentially set it up so that you redirect to any url you like, if it doesn't find a matching controller then it throws an UnknownAction Exception and your override would simply redirect it to the static page that you intended all along... If a controller action DOES exist then everything runs as normal.

My only editorial to this is if an overwhelming percentage of your app will be static html pages such that virtually every page will throw an Unknown action error and you'll be defeating the purpose of running w/ mvc in the first place.

See Also: Display View in folder without Controller or Action in ASP.net MVC

2 Comments

There's a lot happening in the application other than the static pages, thus the mvc. Thanks for the suggestion on HandleUnknownAction. I'll let you know how it works out.
I've used that HandleUknownAction override for something very similar to what you're talking about... Good luck!

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.