0

I am looking to do something that might not be possible, but I will leave it up to the community to decide that.

I have a table called content, in this table are the following: Title and Content.

Based on this information I would like the user to be able to input a title and their content and from the title a page is created so they can go to site.com/title and see the content for that page.

I am sure there is more to this, how ever that's where I require your guy's help. I am not looking to create a CMS, instead I am looking to create a piece of a CMS, the "page generation" part.

I don't have any code as this is an idea and I looking for a direction to take to produce the code.

Thoughts?

TheWebs
  • 12,470
  • 30
  • 107
  • 211

1 Answers1

0

Create a route with a hardcoded controller that takes a string (the Title) as a parameter. Then in that controller, use the Title to pull the Content out of the database. Pass the Content to the view (ensuring the HTML is sanitized) and display it.

routes.MapRoute(
    name: "NotACMS",
    url: "{title}",
    defaults: new { controller = "NotACMS", action = "Index" }
);
Jason Berkan
  • 8,734
  • 7
  • 29
  • 39
  • Is there more information on how to do this? like MSDN docs? other stack questions and so on? – TheWebs Apr 25 '13 at 15:02
  • There is this [question](http://stackoverflow.com/questions/4798334/is-it-possible-to-display-raw-html-from-database-in-asp-net-mvc-3), which discusses displaying HTML from a database. Everything else is regular, simple MVC code. – Jason Berkan Apr 25 '13 at 15:09