-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Mastering Minimal APIs in ASP.NET Core
By :

Let’s start with our first project and try to analyze the new template for the minimal API approach when writing a RESTful API.
In this section, we will create our first minimal API project. We will start by using Visual Studio 2022 and then we will show how you can also create the project with Visual Studio Code and the .NET CLI.
Follow these steps to create a new project in Visual Studio 2022:
Figure 1.1 – Visual Studio 2022 splash screen
API
in the textbox at the top of the window and select the template called ASP.NET Core Web API:Figure 1.2 – Create a new project screen
Figure 1.3 – Configure your new project screen
For this example we will use the name Chapter01
, but you can choose any name that appeals to you.
Figure 1.4 – Additional information screen
Now we are going to show how to create the same project using Visual Studio Code and the .NET CLI.
Creating a project with Visual Studio Code is easier and faster than with Visual Studio 2022 because you don’t have to use a UI or wizard, rather just a terminal and the .NET CLI.
You don’t need to install anything new for this because the .NET CLI is included with the .NET 6 installation (as in the previous versions of the .NET SDKs). Follow these steps to create a project using Visual Studio Code:
dotnet new webapi -minimal -o Chapter01
As you can see, we have inserted the -minimal
parameter in the preceding command to use the minimal API project template instead of the ASP.NET Core template with the controllers.
cd Chapter01 code.
Now that we know how to create a new minimal API project, we are going to have a quick look at the structure of this new template.