I don't know much about the ASP, I wonder if it's a duplicate wheel or nothing, and this demo is:
1, very simple or primitive;
2. Added one page (equivalent to MVC View) for single page Web application
3, Ajax no refresh jump to the new page, and Support H5 Browser Refresh page, forward back to other page
4, Class MVC development mode, Action provides DATA,JS rendering View,data and View development separation
Full code access to Https://github.com/fonshen/Fonshen.SPA
are very simple things, as if there is nothing to say, look directly at the core application code:
First, a single page of the basic page/view/shared/default.cshtml show a menu, click the menu no refresh switch to the new column, the new column can be refreshed, backward forward
<! DOCTYPE html>Two, the 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, VI Sit 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);}}}
Three, 3 action corresponding to 3 Js rendering files
The/js/home/index.js file is responsible for rendering the Datapage.render = function () { Page.Body.html ("index:" +) of the corresponding service side of the index action//page.data. Page.Data.content);};/ //js/home/about.js file is responsible for rendering about Actionpage.render = function () { Page.Body.html ("about->" + Page.Data.page + "page ");};/ //js/home/contact.js file is responsible for rendering the contact Actionpage.render = function () { Page.Body.html ("Contact:" + Page.Data.content );};
Simple ASP. NET CORE single-page Web application "framework"