简体   繁体   中英

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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM