Simple ASP. net core single-page Web application "Framework", asp. netcore
I don't know much about ASP. net core. I don't know if it's a duplicate or nothing. This Demo is like this:
1. Very simple or primitive;
2. added a Page concept (equivalent to the MVC View) to a single-Page Web application)
3. Ajax redirects to the new Page without refreshing, and supports refreshing the Page in the H5 browser, and moving forward and backward to other pages.
4. MVC-like development mode. Action provides Data, Js rendering View, Data and View development separation.
Full code can access https://github.com/fonshen/Fonshen.SPA
They are all very simple things, as if there is nothing to say, simply look at the core application code:
1. The basic page/View/Shared/Default. cshtml on a single page shows a menu. Click the menu to switch to a new topic without refreshing the menu. You can refresh the new topic and move it back.
<! DOCTYPE html>
2. Controller class. Each return this. Page (data) Action corresponds to a Page
using Fonshen.SPA.Extensions;using Microsoft.AspNetCore.Mvc;// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860namespace Fonshen.SPA.Controllers{ public class HomeController : Controller { // GET: /<controller>/ public IActionResult Index() { var data = new { content = "index" }; return this.Page(data); } public IActionResult About(int id) { var data = new { content = "about", page = id }; return this.Page(data); } public IActionResult Contact() { var data = new { content = "contact" }; return this.Page(data); } }}
3. Three actions correspond to three Js rendering files
/// Js/Home/Index. the js file is responsible for rendering Index Action // Page. data corresponds to the dataPage of the server. render = function () {Page.Body.html ("Index:" + Page. data. content) ;}; // js/Home/About. js files are responsible for rendering About ActionPage. render = function () {Page.Body.html ("About-> NO." + Page. data. page + "page") ;}; // js/Home/Contact. the js file is responsible for rendering the Contact ActionPage. render = function () {Page.Body.html ("Contact:" + Page. data. content );};