Lightweight. NET MVC---QMVC

Source: Internet
Author: User

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 ",

2. Add reference tbz. QMVC. dll, :( http://www.wuxiu.org/downloads.html), version tbz. qmvc.1.0,

3. Create a Global. asax file and add the code in the Application_Start and Application_BeginRequest events:

        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,

Note: The Default view in DefaultViews is the Default view. You can also create themes of different themes, such as BlueViews and RedViews, which can be flexibly implemented through the theme function provided by qmvc. Home in defaviews views is directed to HomeController in Controllers. This folder is used to store views in HomeController.

5. Open the "web. config" file in the project and directory and add the configuration items under the system. webServer node:

 
 

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:

                                    
         
                
     

6. Create a web. config file under the DefaultViews directory and add the following code under the Configuration node:

    
       
        
      
     
     
        
                 
       
    
 

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;}            QMVC web page          QMVC is runing!      msg:@model.MSG    

9. Close index. cshtml and press F5 to run it. Check the effect!

Respect originality. For more information, see the source ^_^.

Zookeeper

Related Article

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.