Skip to content
  • iImagine
  • Register
  • Log In

Web Development School

Learning made easy.

  • Books
    • Beginning Web Development with ASP.Net Core & Client-Side Technologies
      • TOC
      • Part 1
        • Chapter 1: Static HTML – Designing the landing page
      • Part 2
        • Chapter 2: ASP.Net Core – Let’s talk Dynamic
        • Chapter 3: Introduction to ASP.Net Core MVC
          [ASP.Net Core v9]
      • Part 4
        • Chapter 7: Using Server Side & Client Side technologies together
          [ASP.Net Core v7 & Angular 15]
  • Environment Setup
    • Installing Angular
    • Installing Visual Studio 2022
    • Installing SQL Server 2022 Express
    • Installing Postman
    • Installing Git for Windows
  • Blog
  • iImagine WebSolutions
  • Events
  • Learning Videos
  • Toggle search form

Create the project: ASP.Net Core MVC

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.

Table Of Contents
  1. Prerequisites
  2. Test the .Net CLI
    • Check the version of .Net
  3. Create a Solution
  4. Create a project
    • Choose a project type
    • Create the project
  5. Add the project to the solution
  6. Open the solution and project in Visual Studio
  7. Run the project
  8. What's Next

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.

Tip: In Windows 11 the URL is a link in the console window. You can point to the link with your mouse and click it while holding down the Ctrl key.

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.

< Prev
Next >

Leave a ReplyCancel reply

Chapter 1: Static HTML – Designing the landing page.

  • Static HTML – Designing the landing page.
  • Let’s get started!
  • Mock your site with HTML
  • Make CSS easy with Bootstrap
  • Mock your content
  • Introducing JavaScript
  • JavaScript Code Improvements
  • Results Data
  • Images and the HTML Image Element.
  • Revisiting Reusability for CSS and JavaScript
  • Reuse for HTML: PART 1
  • Reuse for HTML: PART 2
  • Details Page – Using a Bootstrap Component
  • Creating Links
  • Chapter One Conclusion

Chapter 2: ASP.Net Core – Let’s talk Dynamic

  • Introduction to ASP.Net Core
  • What is .Net?
  • What is ASP.Net
  • Introduction to Entity Framework Core

Chapter 3: ASP.Net MVC Core – Models, Views, and Controllers [ASP.Net Core v9]

  • Introduction to ASP.Net Core MVC
  • Create the project: ASP.Net Core MVC
  • Explore the ASP.Net Core Empty Web Project Template
  • Configure the Application for MVC
  • Create a Controller: Home Controller
  • Create a View: Index View for the Home Controller
  • Install Bootstrap using Libman
  • Create the Layout template
  • Create the Model
  • Install EF Core & Create the Database
  • Seed the Database: Loading test data
  • DI (Dependency Injection): Display a List of Vehicles
  • Repository Pattern: The Vehicles Repo
  • Unit Test 1: Home Controller Can Use Vehicle Repository
  • Unit Test 2: Vehicle Repository Can Return List
  • Add the ImagePath Migration and Thumbnail images to results
  • Pagination: Create a Custom Tag Helper
  • Sorting
  • Category Filter
  • Partial View: Break out the vehicle results
  • View Component: Create dynamic category buttons
  • Create the Details page
  • Create the Create Page

Chapter 7: Using Server Side & Client Side technologies together. [ASP.Net Core v7 & Angular v15]

  • Intro to Full Stack Development
  • Fred’s Cars – Full Stack Development
  • Prepare the environment
  • Create the Visual Studio Solution
  • Add the ASP.Net Core Web API project
  • Add the Angular Project
  • Wire it up!
  • WeatherForecast: Understanding the basics
  • Vehicles API Controller: Mock Data
  • Vehicles Angular Component: Consuming Data
  • Routing and Navigation
  • Using a Component Library: Angular Material
  • Our first Angular Material Component: MatToolbar
  • Configuring for Saas: CSS with superpowers
  • Create the Header & Footer components
  • Displaying Results with MatTable
  • Loading: Using a Progress Spinner
  • MatTable: Client-Side Paging and Sorting
  • MatSidenav: Create a Search Sidebar
  • MatCheckbox: Category Search UI
  • Adding an image to the welcome page
  • Create the database with Entity Framework Core migrations
  • MatPaginator & PageEvent: Custom Server-Side Paging
  • Unit Testing: Custom Server-Side Paging
  • Repository Pattern: VehicleRepository
  • Unit Test: Paging in the Vehicles controller
  • Server-Side Sorting
  • Unit Tests: Sorting
  • Filter (Quick Search)
  • Unit Tests: Filter feature
  • Advanced Search: Categories
  • Unit Tests: Search by category
  • Progress Spinner: Final Fix

TOC

  • What were WebForms?
  • Enter MVC
    • Understanding MVC
    • Advantages of MVC
  • ASP.Net Core MVC – A total rewrite
  • ASP.Net Core 2 MVC – Here come Razor Pages
    • Understanding Razor Pages
  • ASP.Net Core 3 – Dropping the MVC reference
    • Understanding Blazor
  • Dropping the MVC reference
  • Hello .Net 5!
  • What’s Next? – Here comes .Net 6.

Recent Posts

  • Angular Commands Cheat Sheet
  • Installing Git for Windows
  • Installing Postman
  • Installing SQL Server 2022 Express
  • Installing Visual Studio 2022

Recent Comments

No comments to show.

Archives

  • November 2023
  • October 2023
  • June 2023
  • October 2021

Categories

  • Angular
  • ASP.Net
  • Environment Setup
  • See All
  • SQL Server
  • Visual Studio
  • Web API & Rest Services

WordPress Theme Editor

Copyright © 2025 Web Development School.

Powered by PressBook Blog WordPress theme