Simple ASP. NET CORE single-page Web application "framework"

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.