Creating ASP.NET Core Application using MVC Template

Creating ASP.NET Core Application using MVC Template

In this article, I am going to discuss how to create an ASP.NET Core application using MVC Project Template (Web Application (Model-View-Controller)). Please read our previous article before proceeding to this article where we discussed Views in ASP.NET Core MVC application.

Creating an ASP.NET Core MVC Application:

As of now, we have discussed everything using the Empty Project Template and understand the different parts of an ASP.NET Core Application. We also discussed how to set up the MVC Request pipeline in ASP.NET Core Web Application.

But the question is do we really need to set up everything manually to create an ASP.NET Core MVC Application? The answer is NO. The ASP.NET Core provides one built-in project template called MVC which will create an ASP.NET MVC Core MVC Application for us with the required setup. From this article onwards, in this ASP.NET Core MVC course, we are going to create the applications using the MVC Project template. Let us see the step by step procedure to create the same.

Creating an ASP.NET Core Application using MVC Project template:

To create an ASP.NET Core Web Application with MVC Project template. First of all, open Visual Studio 2019 and then click on the Create a new project tab as shown in the below image.

Creating an ASP.NET Core Application using MVC Project template

Once you click on the Create a new project tab, it will open the following Create a new project window. From this window, you need to select the ASP.NET Core Web Application template and then click on the Next button as shown in the below image.

Creating an ASP.NET Core MVC Application

Once you click on the Next button, it will open the Configure Your New Project window. Here, you need to provide the necessary information to create a new ASP.NET Core project. First, give an appropriate name for your project (FirstCoreMVCWebApplication), set the location where you want to create this project, the solution name for the ASP.NET Core Web application. And finally, click on the Create button as shown in the image below.

Creating ASP.NET Core Application using MVC Template

Once you click on the create button, it will open the following Create a new ASP.NET Core Web Application window where you need to select the project template i.e. which type of project you want to create. As we are going to create an MVC Application, so, select the Web Application (Model-View-Controller) Project template and uncheck all the checkboxes from the Advanced section and finally click on the Create button as shown in the below image. Make sure to select the .NET Core and ASP.NET Core 3.1 from their respectively drop-down list.

Create a new ASP.NET Core Web Application

That’s it. Once you click on the Create Button, the project is going to be created with the Web Application (Model-View-Controller) i.e. MVC template with the following folder and file structure.

Web Application (Model-View-Controller) Project template

The MVC Project template by default includes the required setup for MVC. To confirm this, open the Startup.cs class file and you will see the required MVC Services and MVC Request processing pipeline are added by the framework as shown in the below image.

MVC Services and MVC Request processing pipeline

Running the Application:

The MVC Project template creates the Home Controller with some views. Let us run the application and see the output as shown below.

Running the Application

In the next article, I am going to discuss how to pass data to views in ASP.NET Core MVC application with examples. Here, in this article, I try to explain how to create an ASP.NET Core application using MVC Project Template (Web Application (Model-View-Controller)). I hope you enjoy creating an ASP.NET Core application using the MVC Project Template article.

Leave a Reply

Your email address will not be published.