In this Video, I am going to discuss the auto-generated ASP.NET MVC File and File Structure when we create a new ASP.NET MVC application. Please watch our previous Video before proceeding to this Video where we discussed how to create ASP.NET MVC 5 application step by step from scratch.
What is ASP.NET MVC File and Folder Structure?. The Complete ASP.NET MVC Developer Course 2022 [Videos].
Nowadays, the ASP.NET MVC framework becomes more popular among developers because of the separation of concerns (codes) and folder structure. As a developer, it is very important for you to understand the need and use of each file and folder of an ASP.NET MVC application. When we create an ASP.NET MVC 5 application, Visual Studio by default creates the following files and for our application.
Let us discuss the need and use of each File and Folder in detail one by one.
The App_Data folder of an ASP.NET MVC application contains application-related data files like .mdf files, LocalDB, and XML files, etc. The most important point that you need to remember is IIS is never going to serve files from this App_Data folder. In our example, this folder is empty as we dont have any data files. In our upcoming Videos, we will discuss how to store application-related data files in App_Data Folder.
The App_Start folder of an ASP.NET MVC application contains configuration-related class files which are needed to be executed at the time of application starts. The classes like BundleConfig, FilterConfig, RouteConfig, IdentityConfig, etc are stored within this folder. We will discuss the use of each of these class files in detail in our upcoming Videos.
The Content Folder of an ASP.NET MVC application contains static files such as the image files, CSS files, and icons files, etc. When we create a new ASP.NET MVC 5 application, then by default bootstrap.css, Site.css, and bootstrap.min.css files are included by Visual Studio as shown in the image below.
The Controllers Folder of an ASP.NET MVC application contains all the controllers of your application. The Controllers are nothing but classes that are inherited from the base Controller class. The name of the Controller should end with the word “Controller”. It is this class that actually handles the users request i.e. the incoming HTTP Requests and returns a response. In our upcoming Videos, we will discuss the controllers in detail.
The Fonts folder of an ASP.NET MVC application contains the custom font files that are required for the application.
The Models folder of an ASP.NET MVC application contains the class files which are used to store the domain data (you can also say business data) as well as business logic to manage the data. In our example, the Models folder is empty as we have not created any models for our application. In our upcoming Videos, we will discuss Models in detail.
The Views Folder of an ASP.NET MVC application contains all the “.cshtml” files of your application. In MVC, the .cshtml file is a file where we need to write the HTML code along with the C# code. The Views folder also includes separate folders for each and every controller for your application. For example, all the .cshtml files of the HomeController will be in the View => Home folder. We also have the Shared folder under the Views folder. The Shared Folder contains all the views which are needed to be shared by different controllers e.g. error files, layout files, etc.
Now, let us discuss the configuration files which are created by the framework by default:
The Global.asax file in an ASP.NET MVC application allows us to write the code that we want to run at the application level or you can say global level, such as Application_BeginRequest, Application_Error, Application_Start, Session_Start, Session_End, etc. In our upcoming Videos, we will discuss the use of these application-level events in detail.
The Packages.config file in an ASP.NET MVC application is managed by NuGet Package Manager which will keep track of what packages and versions have been installed in your application.
The Web.config file of an ASP.NET MVC application is one of the most useful and important files which contains the application-level configurations such as connection strings, global variables, etc.
Here in this Video, we discussed the ASP.NET MVC File and Folder structure. Once you understand the need and use of each folder and file of an MVC application, then it is easy for you to find, store and organize project-related files.