MVC 5 Chapter II MVC5 Application project Structure _ practical skills

Source: Internet
Author: User
Tags auth configuration settings microsoft sql server parent directory hosting

From the literal meaning of MVC we can notice the M-model, the view-view, the controller-controller, each of them stored in a separate folder under the solution. And there's a lot of useful information to explore, and let's talk less, first we look at the project structure of MVC 5.

With the diagram above, we can clearly understand the project structure of the MVC 5 application, and then we'll explain their respective applications in turn.

App_Data: This folder consists primarily of local storage of applications, which typically contain data stores in the form of files (such as Microsoft SQL Server database files, XML files, and so on).

App_start: This folder contains the configuration logic files for the application, specifically including BundleConfig.cs, FilterConfig.cs, RouteConfig.cs, Startup.Auth.cs

BundleConfig.cs: Registration of the bundled CSS and JS files used.

FilterConfig.cs: Registers external/global filters that can be applied to each action and controller.

RouteConfig.cs: Configures the system routing path for an MVC application.

Startup.Auth.cs: Configures security information for MVC applications, including authentication and authorization configurations, and Third-party authentication Provider

Content: This folder is recommended for storing static content files like CSS and (picture) Images

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

Fonts: This folder is used to store font files that an MVC application might use

Models: This folder is used to store application entity model classes, and entity classes can define objects and application logic.

Scripts: This folder defaults to storing ASP.net Ajax Foundation files and jquery. It is primarily used to store script (JS) files that are supported by the application.

Views: This folder is primarily used to store layout files (. master), view files (. aspx), and view user control files (. ascx) used by MVC applications.

Attentive readers will also notice Global.asax, Startup.cs (new additions to the MVC 5 application) and web.config.

Gobal.asax:

(from MSDN) here Global.asax is primarily a Web application's global settings file that contains code that responds to application-level and session-level events raised by ASP.net or HTTP modules. The Global.asax file resides in the root directory of the ASP.net application. At run time, parse the Global.asax and compile it into a dynamically generated. NET Framework class that derives from the HttpApplication base class. Configure ASP.net to automatically deny any direct URL requests to Global.asax files, and external users cannot download or view the code in them. The Global.asax file is optional. You should create it only when you want to handle an application event or session event.

Web.config:

(from MSDN) The Web.config file is an XML text file that stores configuration information for Asp.netweb applications (such as the most common settings Asp.netweb application authentication), which can appear in every directory in the application. When you pass. NET when you create a new Web application, by default, a default Web.config file is created automatically in the root directory, including the default configuration settings, and all subdirectories inherit its configuration settings. If you want to modify the configuration settings for subdirectories, you can create a new Web.config file in the subdirectory. It can provide configuration information in addition to the configuration information inherited from the parent directory, or you can override or modify the settings defined in the parent directory.
Modifications to the Web.config file at run time do not require a restart of the service to take effect (note: section exceptions). Of course, Web.config files can be extended. You can customize the new configuration parameters and write configuration section handlers to process them.

Focus on the following Startup.cs file:

Startup.cs:

This file is primarily provided to Owin (Open Web Interface for. NET) application, Owin is designed to understand the decoupling server application. For example, in cases where ASP.net identity uses owin security, SIGNALR self hosting use Owin hosting, and so on, our MVC applications have access to Owin, so They all use the startup class defined by Startup.cs. The application of Owin is not detailed here, the reference to own is mainly to illustrate the use of Startup.cs files.

Well, today's article is written here, the content is not much but very organized, clear structure, hope to learn a little enlightenment to friends! In this chapter, friends should have a clearer understanding of the structure of the MVC application, and in the next chapter we will introduce some of the knowledge points for MVC application development (Tips and Tricks).

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.