.NET 6 Minimal APIs: How they have evolved ASP.NET Core (no more controllers)

preview_player
Показать описание
Minimal APIs in .NET 6 have changed the way we can write API endpoints in ASP.NET Core.

No longer do we have to use MVC controllers. We can now write our C# code in the Program class to create our Minimal API, making it a lot more simple.

This video will take an ASP.NET Core Web API that is written using .NET Core 2.1, which we wish to upgrade to .NET 6.

The ASP.NET Core Web API powers an internal blog for a corporate company. The blog is used to communicate the latest news with their employees. Employees are invited to give their feedback on each blog post by adding a comment.

The API only has a small number of HTTP GET and HTTP POST endpoints, and therefore it is a good candidate for one of .NET 6's new features, Minimal APIs.

We go ahead and convert the ASP.NET Core Web API to .NET 6. Afterwards, we merge the Startup configuration into the Program class, and remove the namespace, class and Main method from our Program class.

Finally, we move our API endpoints out of MVC and add them as part of Minimal APIs. In addition, we also set up the endpoints as part of the Swagger documentation, making it easy for us to test out our endpoints.

💻 Download the code example for this demo 💻

📖 Learn .NET and C# with our online courses 📖

► Chapters
0:00 Minimal API introduction
0:49 The scenario
1:13 API endpoints
1:32 What are Minimal APIs?
2:23 The demo
14:37 Minimal API review

#dotnet6 #minimalapi #aspnetcore
Рекомендации по теме
Комментарии
Автор

Very good explanation.
Would you please also do a video on when it is not recommended to use Minimal Apis?

PticostaricaGS
visit shbcf.ru