ASP.NET MVC - Application Folders
To learn ASP.NET MVC, we will build an Internet application.
Part 2: Exploring Application Folders.
MVC Folders
A typical ASP.NET MVC web application's folder structure looks like this:
| Application Information<br>PropertiesReferences<br>Application Folders<br>App_Data FolderContent Folder<br>Controllers Folder<br>Models Folder<br>Scripts Folder<br>Views FolderConfiguration Files<br>Global.asaxpackages.configWeb.config | | | Application Information PropertiesReferences Application FoldersApp_Data Folder <br>Content Folder <br>Controllers Folder <br>Models Folder <br>Scripts Folder <br>Views Folder <br> Configuration Files Global.asaxpackages.configWeb.config | | | | Application Information PropertiesReferences Application FoldersApp_Data Folder <br>Content Folder <br>Controllers Folder <br>Models Folder <br>Scripts Folder <br>Views Folder <br> Configuration Files Global.asaxpackages.configWeb.config |
All MVC application folders have the same names. The MVC framework is based on default naming. Controllers are written in the Controllers folder, views in the Views folder, and models in the Models folder. You do not need to use folder names in your application code.
Standardized naming reduces the amount of code and helps developers understand MVC projects.
Below is a brief overview of each folder's contents:
App_Data Folder
The App_Data folder is used to store application data.
We will introduce adding an SQL database to the App_Data folder in later sections of this tutorial.
Content Folder
The Content folder is used for static files such as style sheets (CSS files), icons, and images.
Visual Web Developer automatically adds a themes folder to the Content folder. The themes folder contains jQuery styles and images. You can delete this themes folder in your project.
Visual Web Developer also adds a standard style sheet file to the project: the Site.css file in the content folder. This style sheet file is the one you need to edit when you want to change the application's style.
We will edit this style sheet file (Site.css) in the next chapter of this tutorial.
Controllers Folder
The Controllers folder contains controller classes that are responsible for handling user input and responses.
MVC requires all controller files to end with "Controller".
Visual Web Developer has already created a Home controller (for the Home and About pages) and an Account controller (for the Login page):
We will create more controllers in later sections of this tutorial.
Models Folder
The Models folder contains classes that represent the application's models. Models control and manipulate the application's data.
We will create models (classes) in later sections of this tutorial.
Views Folder
The Views folder is used to store HTML files (user interface) related to the application's display.
The Views folder contains a folder for each controller.
In the Views folder, Visual Web Developer has created an Account folder, a Home folder, and a Shared folder.
The Account folder contains pages for user account registration and login.
The Home folder is used to store application pages such as the home page and about page.
The Shared folder is used to store views (master pages and layout pages) shared between controllers.
We will edit these layout files in the next chapter of this tutorial.
Scripts Folder
The Scripts folder stores the application's JavaScript files.
By default, Visual Web Developer stores standard MVC, Ajax, and jQuery files in this folder:
Note: The file named "modernizr" is a JavaScript file used to support HTML5 and CSS3 in the application.