In the last module we took a quick look at the MVC software development pattern, its architecture, and the responsibilities of each MVC component. In this module we are going to get started and create the ASP.Net Core MVC project.
Prerequisites
We are going to use a Microsoft IDE (Integrated Development Environment) tool to build Fred’s Cars in the ASP.Net Core MVC framework called Visual Studio.
If you haven’t done it yet, follow the instructions under Environment Setup in the top menu of this website for Installing Visual Studio 2022.
Test the .Net CLI
When you install Visual Studio it also installs .Net and the .Net SDK (Software Development Kit). We should now have access to the .Net CLI (Command Line Interface). So, let’s test it out.
Check the version of .Net
Open up “Developer PowerShell for VS 2022”. Visual Studio installs Developer PowerShell in the new Visual Studio 2022 group in the Windows Start Menu.

We can test the .Net CLI tool at the Developer PowerShell command line by checking the version of .Net we have installed. Type the following command.
dotnet --version
The output results should look similar to the following.

You can see in the screenshot above I am using version 9.X at the time of this writing.
Create a Solution
First we are going to create a Visual Studio solution to hold our projects. Then we will create the ASP.Net Core MVC project and add it to the solution.
Create a folder with the following path and folder name,
“C:\Development\FredsCars\MVC\Module02”.
At the Developer PowerShell Command Prompt, type the cls
(clear screen) command to clean up the output from the dotnet --version
command. You can always do this before any commands I show you to clean up the screen or if you prefer skip this step so you can refer back to all the old output.
Now at the Developer PowerShell Command Prompt, navigate to the new folder and create the solution file with the following commands.
cd C:\Development\FredsCars\MVC\Module02
dotnet new sln -o FredsCars
The output of the commands should look similar to the following.

And, there should be a new FredsCars Folder in the path we created to hold the project and a FredsCars.sln
file.

The -o switch with the value “FredsCars” in the dotnet new sln
command above creates a folder at the path the command prompt is pointed to called FredsCars to hold the output which is the FredsCars.sln
file.
If we had used the -n
or --name
switch like this:
dotnet new sln -n FredsCars
then the FredsCars.sln file would have been created right in the Module02 folder. No new FredsCars folder would have been created to hold the solution file.
Create a project
We just used the .Net CLI’s dotnet new
command to create the solution. Now we are going to use the dotnet new
command to create the project.
Choose a project type
Visual Studio 2022 has a lot of project templates to choose from when creating a project. So many in fact that it has started to get a little confusing in recent years. Let’s take a look at the project types available and choose the best fit.
Type the following command at the command prompt.
dotnet new list
A list of all the .Net project types are listed.

In the above screenshot each type of project has a template name and a short name. The template name describes the type of project and the short name is used to create the project from the command line.
Obviously we want to select one of the ASP.Net Core project templates.
The ASP.Net Core MVC template would be an appropriate choice for this chapter. And the ASP.Net Core Razor template is a good choice for the next chapter.
However, we are going to start with an Empty project, the ASP.Net Core Empty template, because it is cleaner and we can add in only the code and features we need. It also forces us to learn how ASP.Net Core really works.
Sometimes I’ll create a project from the ASP.Net Core MVC template in a play sandbox folder to see what it will crank out and how it would do things for a certain scenario. Sometimes I’ll implement my code that way and sometimes it just gives me an idea of what I want to do.
Create the project
Run the following commands to navigate to the new FredsCars directory and create the Empty Web project.
cd FredsCars
dotnet new web --output FredsCars
The above dotnet new
command will create a subfolder called FredsCars to hold the project files under the FredsCars folder holding the solution file. This folder structure will allow us to add more projects to the solution later under different subfolders; Like a unit test project for testing in FredsCars/FredsCarsTest.
Add the project to the solution
Run the following command at the command prompt to add the FredsCars ASP.Net Core MVC project to the FredsCars solution.
dotnet sln FredsCars.sln add FredsCars/FredsCars.csproj
The output results will tell you that the FredsCars project was added to the FredsCars solution.

Open the solution and project in Visual Studio
Find Visual Studio in the Window Start Menu and open it up.

In the Visual Studio startup dialogue, choose, Open a project or solution.

In the “Open Project/Solution” dialogue, navigate to the FredsCars folder we created that contains the FredsCars.sln file. Select the FredsCars.sln file and click open.

Visual Studio will open and load the FredsCars solution and project as shown in the following image. You should see the solution and project under the solution in the Solution Explorer pinned to the right of the Visual Studio IDE. If Solution Explorer is not opened, open it by Selecting View -> Solution Explorer
from the top menu.

Run the project
Now that we have everything in place we can run our project to test it.
Run the following commands to navigate to the FredsCars subfolder containing the ASP.Net Core Empty Web project files and start up the web application.
cd FredsCars
dotnet run --launch-profile "https"
The results in the console window should look like the following.

The output results shown in the image above show that the ASP.Net Core development server is running in the console window and is hosting the web application at the following URL:
https://localhost:7215
“localhost” in the above URL points to your own development machine. And the numbers 7215 refer to the port number the web application is running on. Your port number will probably be different.
Open up a browser and type in the URL with the port number your project is setup to use.

In the image above, the String “Hello World!” is returned as the result in the browser window from the web application. Wow! We have a running application already. I’ll admit it’s not much yet. But we will fix that very quickly.
What’s Next
In this module we set up the solution, chose a project template that best fits our needs, used it to create the project, and added the project to the solution. We also learned how to run the project from the .Net CLI command line.
In the next module we will take a look at the project files that were created and the code that returns the initial Hello World result.