Microsoft released .NET 7, a new version of .NET, in November 2022. The features have been released in the newer version focusing on performance in mind. If you want to build your first API, this will be a good platform to get started on. In this article, I will be sharing you with the dependencies, and steps to get your API running.
Dependencies:
Visual Studio Community 2022/Visual Studio Code: You can use one of these. In this article, I will be using the Visual Studio Community 2022 version. You can download the community version of Visual Studio from https://visualstudio.microsoft.com/vs/community/
.NET 7 SDK: It comes with the latest version of Visual Studio 2022. If you don’t have it, download it from https://dotnet.microsoft.com/en-us/download/dotnet/7.0 and install it on your machine.
Check .NET version using below command in CMD,
dotnet –version
Create Project:
Open visual studio 2022 and search for .net core web API project type. You will see the ASP.NET Core Web API project, then click on the Next button.
Select the path where you want to save the project. Give the name of the project and click on Next.
Make sure the framework is selected as .NET 7.0. Disable docker configuration for now. And Click on Create button. Project will get created. The project will have a sample controller(API endpoint) named WeatherForecast already created.
The below window will get open when the project gets created.
The project will have swagger configured by default. Run the project(or press F5), it will open the swagger UI in the browser as shown below. You can verify your api endpoint in swagger.