Introduction
ASP.NET is a high-performance, cross-platform, open-source framework for building modern, cloud-based, Internet-connected web applications. It is a rich framework for building web applications and APIs using the Model-View-Controller (MVC) design pattern.
While creating an ASP.NET MVC project, we should be aware of the project folder structure. So, Let’s dive into the topic and have a brief introduction about it.
ASP.NET MVC Folder Structure
While creating a project in ASP.NET MVC Visual Studio(VS) Code creates the following folder structure of the MVC application by default.
App_Start
The App_Start folder contains class files executed when the application starts. Generally, all the configuration files like, e.g., Router Configuration, Filter Configuration, Bundle Configuration.
MVC (V) includes FilterConfig.cs, BundleConfig.cs, and RouteConfig.cs by default.
App_Data
The App_Data folder contains all data required to read & write into the application, data files like LocalDB, XML files, .mdf files, and other data-related files. IIS will never serve files from the App_Data folder.
Content
The Content folder contains static files like Cascading Style Sheet files, images, and icons files. By default, the MVC (V) application includes bootstrap.css, bootstrap.min.css, and Site.css.This Content folder is used for static and publically servable files (*.css).
Controllers
The Controllers folder contains C# class files for the controllers. Controllers are responsible for manipulating the model, handling end-user interaction, and choosing a view to display the UI.
A Controller handles users' requests and returns a response. Each controller class name has "Controller" as a suffix on the class name.
Models
The Models folder contains classes that define objects and the logic for interacting with the database or data items. It includes public properties, which will be used by the application to hold and manipulate application data.
The Model is used by both the Controller and the View to edit and view. It is always better to put model classes into a separate class library project.
Scripts
The Scripts folder contains JavaScript and VBScript files for our MVC web application. By default, MVC (V) includes javascript files for bootstrap, jquery 1.10, and modernizer. We put static and publicly accessible files for jQuery and JavaScript validation files (*.js) in this folder.
Views
The Views folder holds HTML files for the application. The files for displaying the application's user interface are placed here. Generally, a view file is a .cshtml file where you write C# and HTML or VB.NET code.
This folder includes a separate folder for each controller. For example, all the .cshtml files, which will be rendered by HomeController, will be in the View > Home folder.
The View's subfolder is named with the controller-name-prefix, and View is named with the controller action.
Global.asax
When your application has deployed the server, global.asax file is the main file. When the first request comes to the server, it reaches Global.asax first. Global.asax file allows us to write code that runs in response to application_start, application-level events, application_error, such as Application_BeginRequest, session_start, session_end, etc.
