MVC 5 chapter 2 MVC5 application project structure

Source: Internet
Author: User

From the literal meaning of MVC, we can notice that the M-model, View-View, and Controller-Controller are all stored in separate folders under the solution. There is also a lot of useful information worth exploring. Let's talk a little bit about it. First, let's take a look at the MVC 5 project structure.

Through this, we can clearly understand the project structure of the MVC 5 application. Next we will explain their respective applications in sequence.

App_Data: this folder contains local storage of applications. It usually contains data storage in the form of files (such as Microsoft SQL Server database files and XML files.

App_Start: this folder contains the application configuration logic files, including BundleConfig. cs, FilterConfig. cs, RouteConfig. cs, and Startup. Auth. cs.

BundleConfig. cs: registers the bundled CSS and JS files used.

FilterConfig. cs: registers external/Global filters. These filters can be applied to each Action and Controller.

RouteConfig. cs: configure the system route path of the MVC application.

Startup. Auth. cs: configure the Security Information of the MVC application, including Authentication and Authorization configuration, and third-party Authentication Provider.

Content: this folder is recommended for storing static Content files such as CSS and (image) Images.

Controllers: As the name implies, this folder is used to store all Controllers and the Controller must end with "Controller.

Fonts: this folder is used to store the font files that may be used by MVC applications.

Models: this folder is used to store the application entity model class. The entity class can define objects and application logic.

Scripts: this folder stores ASP. NET Ajax Foundation files and Jquery by default. It is mainly used to store Scripts (JS) files supported by applications.

Views: this folder is used to store layout files (. master), view files (. aspx), and view User Control Files (. ascx) used by MVC applications)

Careful readers will also notice that Global. asax, Startup. cs (newly added MVC 5 applications) and Web. config.

Gobal. asax:

(From MSDN) Global. asax is a global setting file for web applications. This file contains the response to ASP. code of application-level and session-level events caused by the NET or HTTP module. The Global. asax file resides in the root directory of the ASP. NET application. At runtime, analyze Global. asax and compile it into a dynamically generated. NET Framework class, which is derived from the base class of HttpApplication. Configure ASP. NET to automatically reject any direct URL requests to the Global. asax file. external users cannot download or view the code. The Global. asax file is optional. You must create an application event or session event only when you want to process it.

Web. config:

(From MSDN) Web. config is an XML text file used to store ASP. configuration information of NETWeb applications (for example, the most common settings of ASP. NETWeb application authentication method), which can appear in every directory of the application. When you pass. after creating a Web application, a default Web application is automatically created in the root directory by default. config file, including the default configuration settings. All subdirectories inherit its configuration settings. If you want to modify the configuration settings of a subdirectory, you can create a Web. config file under the subdirectory. It can provide configuration information other than the configuration information inherited from the parent directory, or rewrite or modify the settings defined in the parent directory. Modifications to the Web. config file at runtime can take effect without restarting the Service (Note: Exceptions in section ). Of course, the Web. config file can be expanded. You can customize new configuration parameters and write the configuration section handler to process them.

Focus on the Startup. cs file:

Startup. cs:

This file is mainly provided to the OWIN (Open Web Interface for. NEt) application. The OWIN is designed to decouple the server application. For example, in ASP. NET Identity uses OWIN security, SignalR self hosting uses OWIN hosting, and so on, all of our MVC applications use OWIN. Therefore, all of them use startup. the Startup class defined by cs. the OWIN application is not described here. The OWN is mainly used to describe Startup. use of cs files.

Well, today's article is written here. The content is not too much, but it is very organized and clear. I hope to give some inspiration to my friends! Through this chapter, we will have a clear understanding of the structure of MVC applications. The next chapter will introduce some knowledge points (Tips and Tricks) of MVC application development ).

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.