Anthony
Anthony

Reputation: 69

ASP.NET MVC How do I add a new page in runtime?

so I am developing a MVC5 project and my situation is this:

I have a view called "Menu Editor" and I want to be able to add new pages from this view. By pages, I mean like, If someone wanted to create a new page called "Help", they write "Help" and press add,then an "Help" option appears in the navbar and you can click it and it redirects you to ".../Help" which would be created in runtime and just be a default view.

How can I do that and can I do that from view?

For the sake of simplicity lets assume I have a fresh ASP.NET MVC project since all I want to learn is how to do it and what is the correct syntax and It has nothing to do with my paragraphs of unsimplified code.

If that helps; I also have DevExpress plugin/extension installed and implemented.

Upvotes: 2

Views: 540

Answers (2)

Clayton C
Clayton C

Reputation: 551

The ideal way of handling this is to have the core stuff handled as normal but adding a sort of database or similar,

In your RouteConfig.cs at the end do a check against this data set and see if any urls are matching the request.

If yes, you can redirect the request to the controller and handle page loading from there.

The content of each page can be stored in files, memory or something of that nature.

Hope this helps.

Upvotes: 0

Lapenkov Vladimir
Lapenkov Vladimir

Reputation: 3218

System should post http request and add <li> node when post is successfull.

  1. Create an MVC action that process post action.
  2. Create AJAX post call to this action when client press "add" button, handle this call and add <li> node.
  3. location.assign("your-url") to get to your created page

Upvotes: 2

Related Questions