MVC: Project File Structure

Default MVC Project File Structure

When setting up a MVC Application the project file structure is as follows:

The main folders are:

Models

Models hold the business logic. Models to represent the data used in the application will be created here.

Views

The views that contain the HTML and other content. By default file _ViewStart.cshtml links to the _Layout.cshtml where the default Bootstrap HTML/CSS is set.

As a developer you can choose to make more folders inside Views to help structure your content.

Controllers

Communicates between the View and Model. MVC uses a 'separation of concerns' approach to development. The controller controls which views are displayed and whether they need the support of the Model (not all pages will).

wwwroot

Location of all 'static' files such as client side Javascript, images and CSS files. May also include HTML files that don't require any .net server side logic

Other core files are:

appsettings.json

As the name implies used for application settings. Is used to store database connection strings.

Program.cs

The main gateway to the application that holds the c# Main method. This calls Startup.cs

Startup.cs

Configures the application using Dependency Injection and controls the order of the middleware methods to be run.

MVC Startup.cs

The default Startup.cs appears as follows:

Startup.cs

Note: The use of app.UseEndpoints() differentiates this from Razor Pages. ASP.net Core 2 makes use of app.UseMvc().