How to Create a web API with ASP.NET Core 3.1

ASP.NET Core is a complete redesign of the previous web framework from Microsoft, called ASP.NET. It is built to run on multiple platforms – Windows, Mac, and Linux – and is lightweight, modular, and supports modern web application development.

System requirements

.NET Core 3.1

Let’s start by downloading .NET Core 3.1 from https://www.microsoft.com/net/download/. In our case, we’ll install the SDK version, which contains all the components that are required for our development environment, including ASP.NET Core.

Once .NET Core is installed on your machine, run the dotnet –help command.

dotnet --help

IDEs and development tools in ASP.NET Core

  • Visual Studio 2019
  • Visual Studio Code and OmniSharp
  • Rider

Setting up an ASP.NET Core project

Step 1 : Create a folder for your sample application called mkdir SampleAPI.

mkdir SampleAPI

Step 2 : Move into the new folder.

cd SampleAPI

Step 3 : Create a new web application based on the empty ASP.NET Core 3.1 web application template.

dotnet new webapi

Step 5 : Run the sample application by executing

dotnet run

Step 6 : Open a browser and go to https://localhost:5001/weatherforecast.

Add Comment