In this article, we will learn how to create an ASP.NET Core MVC web application step by step. Prior to creating the application, let's know about the ASP.NET Core.

What is ASP.NET Core?

ASP.NET Core is an open-source cross-platform framework for developing and building web, cloud, and IoT applications.

Why should we use ASP.NET Core?

Now let's start creating an ASP.NET Core MVC web application.

Step 1. Open Visual Studio.

Step 2. Choose Project Template.

You will see the two project templates.

Choose the ASP.NET Core Web App(Model-View-Controller) Template as shown in the following image.

MVC

After choosing the project template click on Next.

Step 3. Define Project Name and Location.

In the project configuration window, you will see the following options.

Additionally, there is a checkbox, if you have checked it, then the solution file (.sln) and project files will be saved in the same folder. Now Choose the minimum details for ease of understanding as shown in the following image.

Checkbox

After defining the required details, click on the Next.

Step 4. Choose the Target Framework.

Choose the target framework .NET 5 which is the latest or you can choose based on your requirements, skip the other details for ease of understanding as shown in the following image.

Target Framework

After providing the required details, click the create button. It will create the ASP.NET Core MVC web application as shown in step 5.

Step 5. Understanding ASP.NET Core MVC Folder Structure.

The following is the default folder structure of the ASP.NET Core ASP.NET MVC application.

 Folder Structure

Let's understand the preceding project folder structure in brief.

  1. The wwwroot folder: The wwwroot is the default root folder for storing the static files related to the project and those files can be accessed programmatically with a relative path.
  2. Controller Folder: The controller folder contains the controller classes where the operation-related code is written.
  3. Model Folder: The Models Folder contains the domain or entity classes. Models can be written anywhere in the solution such as in a separate class library or folder etc.
  4. Views Folder: The Views folder holds the razor pages which are responsible for showing and getting the data from the users.
  5. The appsettings.json File: The appsettings.json folder contains the configuration and secret details of the application.
  6. Program.cs File: The Program.cs is the starting point of the application which will create the host for an application to run the application.
  7. Startup.cs File: The Startup.cs file allows to configuration of the behavior of the application such as defining the routes, dependency injection, etc.

Step 6. Run the ASP.NET Core MVC Application.

You can run the application with default contents or let open the Index.cshtml file and put some contents there. Now press F5 on the keyboard or use the run option from Visual Studio to run the application in the browser. After running the application, it will show in the browser as shown in the following image.

Run the ASP.NET

I hope from the preceding step-by-step demonstration, you have learned how to create the ASP.NET Core MVC Web Application.

Summary

I hope this article is useful in understanding how to create an ASP.NET Core MVC web application. In the next article, we will learn how to perform the CRUD operation in an ASP.NET Core MVC application.

Read more articles on ASP.NET.