.NET 6 Minimal APIs sample using ASP.NET Core

Download a sample of using .NET 6 Minimal APIs.

This ASP.NET Core Web API is used as the datasource by a corporate company to host an internal blog. The blog is used to post the latest news to their employees.

C# coding challenges

C# coding challenges

Our online code editor allows you to compile the answer.

The blog displays the latest news, and it also allows the employees to post comments about each news article. This is so they can get feedback from their workers.

The API only has a small number of endpoints, and this means that it's a good candidate for using Minimal APIs.

In the example, there are a number of .NET 6 changes implemented, including:

  • Adding the web application's configuration into the Program class.
  • Removing the namespace, class and Main method from the Program class.
  • Using Minimal APIs.

Software

This is the software that will need to be installed onto your machine.

  • Visual Studio 2022 Preview 6 or above. It will work with the free community version.
  • .NET 6.0 SDK RC 2 or above. Visual Studio 2022 should already have the .NET SDK installed.

Get the application working

These are the steps to get the application working.

  • Fill out the code example form. We will send you an email where you can download the source code.

You are now ready to go.

Open the project in Visual Studio

Open up RoundTheCode.FrontEndPostApi.sln in Visual Studio 2022.

Start the project in Visual Studio.

Hit https://localhost:8001, and you can test out the API endpoints that are being used with Minimal APIs.

More information

Watch our video where we go ahead and convert this ASP.NET Core application from .NET Core 2.1 to .NET 6.

In addition, you can read about how .NET 6 Minimal APIs has evolved ASP.NET Core.