Create a New ASP.NET Project

ASP.NET is a framework in the .NET Core family that is used to build web applications. While ASP.NET Core can be used to build a wide variety of web applications, we will be focusing on using it to build MVC web applications.

Getting Started

To create a new ASP.NET Core MVC project, start a new project in Visual Studio.

Note

You are creating the inital MVC template. You will not have the routes seen in the video.
You will add these to your project in the next chapter.

Windows Users

  1. Use the Get started Menu to Create a new project.

  2. When selecting the type of project, select ASP.NET Core Web App (Model-View-Controller).

    There are 2 ways to find this easily:

    1. Use the search bar.

    2. Select “Web” from the dropdown menu.

    Once you have your project type, click Next.

  3. Name your project HelloASPDotNET and put it in the appropriate directory for all of your classwork. Hit Next.

  4. Select the Framework. We are going to use .NET Core 6.0. You do not need to adjust any other options at this point. Select Create!

  5. Visual Studio creates a fully-functional web application for you.

Tip

Troubleshooting: This tutorial for Windows can help you if you are stuck.

Mac Users

  1. Open VSC and navigate to the folder you would like to make your new app in the integrated terminal.

  2. Run this command in your terminal: dotnet new mvc -o HelloASPDotNET.

  3. Once the terminal is ready, run code -r HelloASPDotNET.

  4. Visual Studio Code opens a fully-functional web application for you!

Tip

Troubleshooting:

This tutorial can help you if you are stuck using the C# Dev Kit to work with ASP.NET Core MVC projects.

All Users

  1. Now launch the application!

    1. Mac Users: Click Run project in the upper right-hand corner.

    2. Windows Users: Select HelloAspDotNet (or whatever you named your project) and try launching the application if it doesn’t work initially.

  2. Eventually, your browser will open and display your application. Take note of the port number in the address bar. You should see localhost:XXXX. This means your computer is serving the web page.

Tip

Troubleshooting: Refer to the guides mentioned above

Explore the Code

In the Controllers directory, check out HomeController.cs. Microsoft provided the code in HomeController and that is why our application ran immediately after we created it and was full of content.

Check Your Understanding

Question

True/False: You should take note of the port number the server is using to run your application.