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.
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
Use the Get started Menu to Create a new project.
When selecting the type of project, select ASP.NET Core Web App (Model-View-Controller).
There are 2 ways to find this easily:
Use the search bar.
Select “Web” from the dropdown menu.
Once you have your project type, click Next.
Name your project
HelloASPDotNET
and put it in the appropriate directory for all of your classwork. Hit Next.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!
Visual Studio creates a fully-functional web application for you.
Troubleshooting: This tutorial for Windows can help you if you are stuck.
Mac Users
Open Visual Studio for Mac and select New
The type of project is a Web Application (Model-View-Controller). In the left-side menu, select App from under the Web and Console list. Continue on to the next screen.
Target Framework will be
.NET 6.0
. You don’t need to adjust any other settings at this time.Name your project
HelloASPDotNET
and put it in the appropriate directory for all of your classwork. Hit Next.Visual Studio creates a fully-functional web application for you.
Troubleshooting: Microsoft created a tutorial for creating an MVC in Visual Studio, but for the Mac version they recommend the following guide .
Mac users, the guide is working with .NET 7.0
. Make you that you are using .NET 6.0
as the process is identical.
All Users
Now launch the application!
Mac Users: Click Run.
Windows Users: Select
HelloAspDotNet
(or whatever you named your project) and try launching the application if it doesn’t work initially.
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.
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
True/False: You should take note of the port number the server is using to run your application.