ASP. NET! This word represents a word Fat! Because he is always bound with too many classes and too many functions! You may use it. If you decompile or read their open source code, will you be unable to find a direction in the sea? Whether it is Web form or MVC.
QMVC as its name implies! Q = Quick! He worships flexible, simple, and fast! If you like these features, continue reading them. I will introduce you to a new. NET MVC framework named QMVC.
What is QMVC?
QMVC is a high-performance mvc Framework. Q is short for Quick, and MVC is short for Model, Controller, and View. QMVC is developed using the C # programming language and the Microsoft. NET framework 4.5 class library. It is used for B/S structure project development. The author of the QMVC Project, Mr. Wu Shifu, is a Chinese Buddhist believer. He once said that the project is free and open-source because of its good fortune, good deeds, and Buddhist principles.
Like Standard MVC, QMVC uses controllers, models, and views to process program logic, such as writing data to databases, uploading files, and other business processes. After the Controller loads data, encapsulate the data into a model class and pass it to the view. The view displays the page content through the data in the model. In this way, the program idea is clearer, and the artist can simply modify the display layer, because the program code is independent from the template.
How to download QMVC
QMVC Official Website: Ghost. The wuxiu. QMVC project is the core class library of QMVC and is used to support the running of the MVC framework. Wuxiu. QMVC. DEMO is a sample project of QMVC, which demonstrates the basic functions of QMVC. The wuxiu. QMVC. APPS. DEMO project demonstrates the sample code of the qmvc app.
QMVC source code
First, we will introduce the namespace. All namespaces begin with wuxiu. QMVC, where wuxiu is the Pinyin of the Chinese author's name. Among them, the wuxiu. QMVC. APPS namespace stores all the supporters of the QMVC application-related class libraries, most of which inherit from the basic class implementation in wuxiu. QMVC. The tbz. QMVC. Router namespace mainly stores the Code related to the URL routing function of QMVC, which is used to process the Url address analysis function. The wuxiu. QMVC. APPS. Router namespace is used to process url routing in qmvc app mode.
Start creating a QMVC Project
1. Open Visual studio and create an ASP. NET blank Project Based on. NET framework4.5. The project name is "myqmvc ",
Protected void Application_Start (object sender, EventArgs e) {RouterManager. registerDefaultRouter (this. getType ();} protected void Application_BeginRequest (object sender, EventArgs e) {wuxiu. QMVC. QMVCCore. page_BeginRequest (new HttpContextWrapper (this. context ));}
4. Create the "Controllers, Models, and DefaultViews" folder in Solution Explorer, and create the Home folder in DefaultViews,
<Modules runAllManagedModulesForAllRequests = "true"/>
Note: This indicates that iis will send all requests to the module program. This indicates that all requests are sent to asp.net for processing first.
Add the following content to the compilation node under the system. web node:
<assemblies> <add assembly="System.Web.WebPages.Razor2, Version=9.0.0.1, Culture=neutral, PublicKeyToken=14679ed9c77dd5f5" /> <add assembly="System.Web.WebPages2, Version=9.0.0.1, Culture=neutral, PublicKeyToken=14679ed9c77dd5f5" /> <add assembly="System.Web.Razor2, Version=9.0.0.1, Culture=neutral, PublicKeyToken=14679ed9c77dd5f5" /> </assemblies> <buildProviders> <remove extension=".cshtml"/> <add extension=".cshtml" type="System.Web.WebPages.Razor.RazorBuildProvider, System.Web.WebPages.Razor2"/> </buildProviders> </compilation>
6. Create a web. config file under the DefaultViews directory and add the following code under the Configuration node:
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor2"> <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor2" requirePermission="false" /> <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor2" requirePermission="false" /> </sectionGroup> </configSections> <system.web.webPages.razor> <pages pageBaseType="wuxiu.QMVC.MVCRzorPageBase"> <namespaces> <add namespace="wuxiu.QMVC" /> </namespaces> </pages> </system.web.webPages.razor>
This code tells asp.net compiler that the Razor template engine is handed over to qmvc for compilation. Improper configuration will cause an error in Razor engine browsing.
7. Here, a QMVC project framework is built, followed by a simple QMVC program. Create the next class file "Home_Index.cs" in the Models directory. The Code is as follows:
using System; namespace myqmvc.Models { public class Home_IndexModel { public string MSG { get; set; } } }
Create a ComeController. cs class file under the Contrllers directory (Note: it must end with Controller). The Code is as follows:
using System;using System.Web;using wuxiu.QMVC;namespace myqmvc.Controllers{ public class HomeController:ControllerBase { public ViewResult Index() { Models.Home_IndexModel model = new Models.Home_IndexModel(); model.MSG = "hello world!"; return View(model); } }}
8. Create the next index. cshtml view in DefaultViews \ Home,
The Code is as follows:
@{myqmvc.Models.Home_IndexModel model = Model;} <!DOCTYPE html>
9. Close index. cshtml and press F5 to run it. Check the effect!
Respect originality. For more information, see the source ^_^.