An introduction to the MVC development pattern in ASP

Source: Internet
Author: User
Tags actionlink

For more information, please refer to: http://www.runoob.com/aspnet/mvc-intro.html

1.MVC is one of three types of ASP. MVC is a pattern of creating WEB applications using MVC (Model View Controller-View-controller) design.

2.MVC -Application Folder

The folder names for all MVC applications are the same. The MVC framework is based on the default naming. The controller is written in the Controllers folder, and the view is written in the Views folder, and the model is written in the Models folder. You no longer have to use the folder name for your application code.

The App_Data folder is used to store application data.

Content folders are used to hold static files, such as style sheets (CSS files), icons, and images.

Controllers folder: MVC requires that the names of all controller files end with "controller".

Models folder

Views folder: Used to store HTML files related to the display of the application (user interface). Contains a folder for each controller.

The account folder contains pages for registering and signing in for user accounts.

The home folder is used to store application pages such as home pages and about pages.

Shared folders are used to store views shared between controllers (master pages and layout pages).

The Scripts folder stores the application's JavaScript files.

3.MVC -styles and layouts

The file _layout.cshtml represents the layout of each page in the application. It is located in the Shared folder in the Views folder.

  HTML helper:<li>@Html. ActionLink("Contacts", "Contact", "Home") </li>

        

@Url. Content ()-The URL content will be inserted here.

@Html. ActionLink ()-The Html link will be inserted here.

Razor syntax

Add Style: The application's style sheet is site.css, which is located in the Content folder.

  _viewstart File: The _viewstart file located in the Views folder contains the following content:

@{

Layout = "~/views/shared/_layout.cshtml";
}

  

This code is automatically added to all views displayed by the application.

If you delete this file, you must add this line of code to all views.

4.MVC -Controller (Controllers folder contains control classes responsible for handling user input and Response )

MVC requires that the names of all controller files end with "controller".

MVC maps URLs to methods. These methods are referred to as "controllers" in the class.

The controller is responsible for processing incoming requests, processing inputs, saving data, and sending responses back to the client.

The controller file in the application HomeController.cs, defines two controls Index and about .

The files index.cshtml and about.cshtml in the Views folder define the ActionResult view in the Controller Index () and about ().

5.MVC -View

Views Folder: viewsA folder stores files (HTML files) that are related to the application display (user interface). It could be HTML, ASP, ASPX, cshtml, and vbhtml.

The Views folder contains a folder for each controller.

The account folder contains pages for registering and signing in for user accounts.

The home folder is used to store application pages such as home pages and about pages.

Shared folders are used to store views shared between controllers (master pages and layout pages).

ASP. net file type:

Index file: File index.cshtml represents the Home page of the application. It is the default file for the application (home file).
 "Home page";}  
About file: File about.cshtml represents the About page of the application.
 "aboutUs";}  

6.MVC -SQL database

VS 2013 connection to SQL Server 2008: https://jingyan.baidu.com/article/a3f121e4a23c63fc9052bba7.html

An introduction to the MVC development pattern in ASP

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.