Understanding the structure, files and folders in Asp.Net MVC 5 application

Spread the love

MVC is one of the latest hot topics in various programming languages including Microsoft’s Asp.Net. Before going into the details of the various files and folders that are used in an asp.net mvc 5 application, let’s first understand briefly what really MVC is. In the simplest language, MVC can be defined as a three tier design pattern in which the application is divided into three interconnected parts namely Model, View and Controller, where the Model’s role is to interact with the data, the View’s role is to handle the user interface and the Controller’s role is to handle the interaction between the application and the user, define the overall application flow as well as the application specific logic.

Now that we have a general idea of what MVC is, let’s understand the MVC structure and see what all folders and files are there in an MVC application (Note: I will be explaining in detail how to perform CRUD operations in Asp.Net MVC 5 using entity framework in the next article. For now let’s just concentrate on understanding the structure, files and folders in an asp.net mvc5 application.) I just created a new mvc 5 project named CRUD_MVC_EF and following is how the solution explorer of a newly created asp.net mvc 5 project will look like.


MVC refers to Model View Controller, and you can see these 3 folders in the solution explorer and they are explained below:

1. Models folder: The Models are used to interact with the data. The Models folder contains classes that define the data that we are working with and also it contains the business logic of the application.

2. Views folder: The Views define the application’s user interface, i.e how the web page will look like.

3. Controllers folder: The Controllers folder contains classes that handles the interaction between the application and the user, defines the overall application flow as well as the application specific logic.

Apart from Models, Views and Controllers folders, you will find the following folders in your asp.net MVC 5 application:

4. Properties folder: Properties folder contains the AssemblyInfo.cs file which defines the various general properties of the assembly, like the Assembly Title (which will be your project’s name), Assembly Description, Assembly Configuration, Assembly Version, Assembly File Version etc.

5. References folder: If you are aware of asp.net applications, References folder in mvc is much like the Bin folder in asp.net. You can add reference to dlls or add a web reference like we do while using web service or add a service reference like we do in WCF (Windows Communication Foundation) in asp.net and these referenced files will show up in the References folder.

6. App_Data folder: App_Data folder is used to store local database, which you can access anytime from the project, since it’s always going to stay where your code files will be hosted.

7. App_Start folder: App_Start folder contains various configuration class files to manage various settings related to the application start. All these settings are registered in the Application_Start event defined in the Global.asax file

8. Content folder: Content folder contains css files that define the look and feel of your application.

9. Fonts folder: Fonts folder contains the fonts that are used in your application.

10. Scripts folder: Scripts folder contains the scripts files (jquery/javascript etc) that are used in the application.

Also following are the files that you will find in your asp.net MVC 5 application:

11. ApplicationInsights.config file: ApplicationInsights.config file is used to gain insights into your application. It monitors your live application to help you detect and diagnose any performance issues and exceptions as well as analyse how your application is used.

12. Favicon.ico file: Favicon.ico is the icon you see in the browser title when you run your application. Of course you need to do some settings before the icon starts showing in the browser title.

13. Global.asax file: Global.asax file is used to handle the application level events. Following are the application level events that can be handled in Global.asax file:
Application_Start – This event is triggered when the application starts for the first time.
Application_Init – This event is triggered when the application initializes for the first time.
Application_BeginRequest – This event is triggered each time a new request comes in.
Application_EndRequest – This event is triggered when the request ends.
Application_AuthenticateRequest – This event is triggered when the request needs to be authenticated.
Application_Error – This event is triggered when an application level error occurs.
Application_End – This event is triggered when the application times out or ends.
Session_Start – This event is triggered when a user session starts.
Session_End – This event is triggered when a user session ends.

14. Packages.config file: This file provides information about the various packages that are being used in the application, along with their version and target framework.

15. Project_Readme.html file: This is the first page that you see when you open an asp.net mvc 5 application in Visual Studio. It is just a simple HTML file containing many useful links for asp.net MVC beginners to learn. The page includes links for Bootstrap, Authentication and Nuget packages. Apart from these, the page contains several links under categories like customizing app, deploy and help.

16. Startup.cs file: This file is used to manage the startup related configurations for the application.

17. Web.config file: This file is used to manage the configuration of the application such as defining the connection string(which is used to connect to a database) and appsettings which is used to define application level settings.

Now that we understand the asp.net MVC 5 structure and the various files and folders in it, we are ready to dive into the coding and write some actual code to build an asp.net MVC 5 application, and that’s what exactly we will be doing in our next article. So stay tuned.

Leave a Reply

Your email address will not be published. Required fields are marked *