The 12th chapter of MVC Project Overview

Source: Internet
Author: User
Tags configuration settings

A piece of nonsense: understand, the code to knock over is not the knowledge of the real learning, learn a knowledge: 1. Summarize knowledge characteristics, 2. Extrapolate application

----------------------------------------------------------

Note: When you deploy the server, you should <compilation debug= "false" targetframwork= "4.0" > in the configuration file. Debug must be "false"

----------------------------------------------------------

First, MVC project template:

1.Empty (Empty Project): Contains the minimum files required by the MVC framework.

2.Basic (Basic project): Added some structure (layout, JS library file, CSS style (form element and validation) on the basis of an empty project, which is the most commonly used template. No default authentication is used.

3.Internet Application and Intranet application: further enrich, providing a more complex starting point, using different authentication mechanisms to adapt to the respective network environment.

4.Moblie application: Improved on the Internet application template, optimized for mobile devices.

5.Web API: To create a project that can use the new features of the MVC 4 Web API.

In basic, Internet application, Intranet application three templates, the Internet Application project is the most complex because it implements a complete user management and authentication system that introduces a large number of views.

Ii. Overview of the MVC project:

  

folder or file

Describe

Note

/app_data

Place private Data: An XML file, SQLite, a SQL Server database file, or other basic file storage (data) library

IIS does not have content services for this folder (the Web cannot be requested)

/app_start

Contains configuration settings for the project core: routing, filters, and other content packages (script style bundles, etc.)

/bin

stores compiled assemblies for MVC applications, not referenced assemblies in the GAC (global assembly Cache)  

IIS does not have content services for this folder (the Web cannot be requested). "Show All Files" in the project to see. Compiling the generated binaries, usually they should not be placed in source control

/content

Place static content: CSS files, images, etc.

Convention, not necessary.

/controllers

Placing the Controller class

Convention, the Controller class can be placed anywhere, or define a model class in a separate project

/models

Place a view model or a Domain model class (simple project).

Conventions, typically define a domain model with a dedicated project, which puts only the view model.

/scripts

Storing JS libraries, jquery and several popular libraries Convention, can change
/views Save views and partial views , typically named folders by associated controller /views/web.config prevents IIS from serving this directory content and must be rendered through the action method
/views/shared Save layouts, shared views (non-dedicated)
/views/web.config is not an application configuration file. Contains a full view of the configuration required to work with ASP. To prevent IIS from invoking the view, the default import namespace for the view
/global.asax The Global ASP. NET Application class. The Background code class (Global.asax.cs) is used to register the routing configuration , to establish code that is involved in program initialization, downtime, and when an unknown exception occurs. The role of Global.asax in Web Form
/web.config The application configuration file. The role of Web. config in the website form

Iii. Overview of MVC optional Projects

File or folder Describe
/areas One way to divide a large application into smaller fragments. (MVC)

/app_globalresources

/app_localresources

Contains the resource file used to locate the Web Form page
/app_browsers An XML file containing. Browser that describes the identity of each Web browser and the capabilities they have
/app_themes A theme (. skin file) that contains a Web form that affects the rendering of a Web Form control

Iv. conventions in MVC

1. Recommended user's contract: Scripts folder, etc.

2. "Contract is better than configuration": You do not need to explicitly configure the association between the Controller and its view, as long as you follow the naming convention, such as:

(1) Controller class Convention , end with "Controller";

(2) View Conventions , views and partial views are placed in the/views/< Controller name > folder (ignoring the end controller);

(3) Layout Conventions , the underscore (_) character is prefixed with the filename and placed in the/views/shared folder. In addition to the empty project template, Vs creates a layout named _layout.cshtml. By default, this layout is applied to all views through the/views/_viewstart.cshtml file.

Note: only unhandled exceptions will cause the debugger to break and the exception to be caught and handled in the try...catch block, then the exception becomes processed .

The 12th chapter of MVC Project Overview

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.