Sunday, January 22, 2023

Getting started with Minimal API - The first project

This blog post explains, how to create your first Minimal API project using Visual Studio 2022 with .NET 7.

Step 1: Launch VS 2022 or higher 

Step 2: Choose Core Web API

Step 3: Click Next and Enter the Project Name, Location name and Solution Name


Step 4: Choose Framework Version as .NET 7 & the minimum requirement is .NET 6.

Authentication Type: None

Configure for HTTPS: Yes. Do check the checkbox.

Enable Docker: No. Don’t Check the checkbox

Below are the important to enable Minimal API.

Use Controllers (uncheck to use Minimal API): No (Don’t check the checkbox)

Enable OpenAPI Support: Yes. Do check the checkbox.

Do not use top-level statements: Yes. Do check the checkbox.


Step 5: Once the application is successfully created, it appears like the below.



Step 6: Press F5, to run the application.

The Swagger UI page has been launched and you can view the Weatherforecast API as below.

Step 7: Click on the /weatherforecast API name, click Try it out, execute and you can see the results as below.


Happy Coding !!

No comments:

Post a Comment