Minimal APIs are architected to create HTTP APIs with minimal dependencies. They are ideal for microservices and apps that want to include only the minimum files, features, and dependencies in ASP.NET Core.
TLDR; You can use controllers or minimal APIs
The examples below are from the tutorial: Create a minimal web API with ASP.NET Core
Setup
Add the following nuget packages
- Microsoft.EntityFrameworkCore.InMemory
- Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
1 | using Microsoft.EntityFrameworkCore; |
Endpoints
MapGet
1 | app.MapGet("/", () => "Hello World!"); |
MapPost
1 | app.MapPost("/todoitems", async (Todo todo, TodoDb db) => |
MapPut
1 | app.MapPut("/todoitems/{id}", async (int id, Todo inputTodo, TodoDb db) => |
MapDelete
1 | app.MapDelete("/todoitems/{id}", async (int id, TodoDb db) => |