Generating our REST API
In this section, we'll use our dotnet
command to quickly download the required libraries and generate an initial REST API, which we can then modify to suit our needs.
The dotnet
command includes various templates for different types of projects. To see a list of all templates, we can run the dotnet new --list
command. One of the templates is named webapi
, which will generate a REST API for us. We can use this template by running the following command in PowerShell:
dotnet new webapi -o App\App.WebApi
This will create a new folder, named App
, that contains our REST API nested inside the App.WebApi
folder (we'll take advantage of this nested folder structure in future sections). After navigating to the App\App.WebApi
folder, we can launch our API by running the following command:
dotnet watch run
Our REST API will start running and open a page in the browser so we can test it, as seen in the following screenshot: