Minimal APIs versus MVC controllers in .NET 10: programming model, binding and validation differences (built-in Minimal API validation in .NET 10), endpoint filters versus MVC filters, conventions, OpenAPI, Native AOT support, testability and how to choose.
Both sit on the same foundation: endpoint routing, middleware, DI, authentication and OpenAPI. The difference is the programming model. Minimal APIs map handlers directly with MapGet/MapPost, organise with route groups, return TypedResults, use endpoint filters, support Native AOT, and in .NET 10 get built-in DataAnnotations validation with AddValidation(). Controllers group actions in classes and bring the full MVC feature set: [ApiController] behaviours (automatic 400s, binding inference), the five MVC filter types, custom model binders, input/output formatters with content negotiation and JSON Patch. For a new API service I default to Minimal APIs organised by feature; I choose controllers when the team relies on MVC filters, formatters or existing conventions. The trade-off is less ceremony and AOT versus a richer, more conventional framework.
"The first thing to say is that they are not two frameworks. Since .NET 6, Minimal APIs and controllers both produce endpoints in the same routing system, run through the same middleware, use the same DI container, authorisation policies and OpenAPI generation. So the decision is about the programming model and a few features, not performance or capability in general.
Minimal APIs map a handler straight to a route. Parameters are bound from route, query, headers, body or DI by inference, I return
TypedResultsso the response types are known at compile time and show up in OpenAPI, and I organise them withMapGroupand one extension method per feature. Cross-cutting logic goes in endpoint filters. They work with Native AOT through the Request Delegate Generator, and since .NET 10,builder.Services.AddValidation()validates DataAnnotations on parameters and returns a ProblemDetails 400 automatically, which closed the biggest gap. Controllers give the full MVC stack:[ApiController]with automatic 400s and binding source inference, authorisation, resource, action, exception and result filters, custom model binders and value providers, input and output formatters with content negotiation, and JSON Patch.For a new HTTP API I default to Minimal APIs with feature folders. I choose controllers if the team already has a large MVC codebase, needs XML or other formatters, or relies on filters like resource filters. The mistake I see is turning this into a religious debate or writing Minimal APIs as one 2,000-line
Program.cs. Structure matters far more than which style you pick."
| Minimal APIs | Controllers | |
|---|---|---|
| Definition | app.MapGet("/orders/{id}", handler) |
[HttpGet("{id}")] action in a ControllerBase class |
| Organisation | Route groups, extension methods per feature | Classes, areas, conventions |
| Validation | .NET 10 AddValidation() (DataAnnotations), endpoint filters, FluentValidation |
[ApiController] automatic 400 from ModelState |
| Cross-cutting | Endpoint filters (IEndpointFilter) |
Five MVC filter types |
| Binding | Inference + [AsParameters], TryParse/BindAsync |
Model binders, value providers, [FromX] |
| Output | TypedResults, JSON by default |
Formatters, content negotiation (JSON, XML) |
| Native AOT | Supported | Not supported |
| Testing | Handlers as static methods; WebApplicationFactory |
Controller unit tests; WebApplicationFactory |
| Situation | Choice |
|---|---|
| New microservice or BFF, small team | Minimal APIs |
| Native AOT or serverless cold start matters | Minimal APIs |
| Large existing MVC API, shared filters | Controllers |
| Needs XML/custom formatters or JSON Patch | Controllers |
| Server-rendered UI | Razor Pages or MVC views (not this question) |
A team migrating a 60-endpoint internal API from controllers to Minimal APIs measured roughly 10–15% higher requests per second in a synthetic benchmark, but no change in p95 latency in production because every request spent 30+ ms in SQL. The real win was start-up time under Native AOT (from about 1.5 s to under 200 ms), which mattered for scale-to-zero on Azure Container Apps.
Checks whether the candidate understands both models and chooses based on facts rather than fashion.
Green flags
[ApiController], AOT, .NET 10 validation.Red flags
MapGet(...) ─┐
MapControllers() ─┼─► EndpointDataSource ─► DFA matcher ─► RequestDelegate per endpoint
MapRazorPages() ─┘
A controller action becomes an endpoint whose RequestDelegate runs the MVC action invoker: it creates the controller, runs the filter pipeline, model binding, validation and result execution. A Minimal API handler becomes an endpoint whose RequestDelegate is generated by RequestDelegateFactory (runtime, using expression trees) or the Request Delegate Generator (compile time, source-generated, required for Native AOT). That generated delegate does binding and result writing directly, which is why it is lighter.
HttpContext, CancellationToken, ClaimsPrincipal injected specially. Custom types bind via static TryParse or static BindAsync. [AsParameters] groups parameters into a record.[FromForm], [FromHeader], custom IModelBinder, binding of complex types from query strings, and [ApiController] source inference.ModelState; [ApiController] short-circuits with a ValidationProblemDetails 400 if invalid.AddValidation() plus a source generator discovers types with validation attributes and adds an endpoint filter that validates parameters and returns a 400 ProblemDetails. Before .NET 10 you needed an endpoint filter or a library.MVC filters run inside the action invoker in stages (authorisation → resource → model binding → action → exception → result). Endpoint filters wrap only the handler invocation, with access to the bound arguments via EndpointFilterInvocationContext.Arguments. There is no direct equivalent of resource or result filters in Minimal APIs; middleware or endpoint filters cover most cases.
Minimal APIs avoid controller activation, the filter pipeline and ModelState. Microsoft's benchmarks show higher throughput, but in real services the database dominates. Native AOT requires the trimming-safe, source-generated path, which MVC (reflection-heavy) doesn't support.
GET /orders/{id} both ways in one app and compare the OpenAPI output.builder.Services.AddValidation() and a [Range] attribute on a Minimal API record; post invalid data and read the 400.bombardier -c 64 -d 30s and compare RPS.PublishAot=true and measure start-up time and image size.The same endpoint as a Minimal API and as a controller, with .NET 10 validation.
// Program.cs
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddValidation(); // .NET 10: DataAnnotations validation for Minimal APIs
builder.Services.AddControllers(); // only if you also use controllers
builder.Services.AddSingleton<IOrderStore, InMemoryOrderStore>();
var app = builder.Build();
// Minimal API: handler mapped directly; Results<...> documents both outcomes
app.MapPost("/minimal/orders", async Task<Results<Created<Order>, ValidationProblem>> (
CreateOrder cmd, IOrderStore store, CancellationToken ct) =>
{
var order = await store.AddAsync(cmd, ct);
return TypedResults.Created($"/minimal/orders/{order.Id}", order);
});
app.MapControllers();
app.Run();
public sealed record CreateOrder([Required] string Sku, [Range(1, 100)] int Quantity);
public sealed record Order(int Id, string Sku, int Quantity);
public interface IOrderStore { Task<Order> AddAsync(CreateOrder cmd, CancellationToken ct); }
public sealed class InMemoryOrderStore : IOrderStore
{
private int _next;
public Task<Order> AddAsync(CreateOrder cmd, CancellationToken ct) =>
Task.FromResult(new Order(Interlocked.Increment(ref _next), cmd.Sku, cmd.Quantity));
}
// Controller: [ApiController] gives automatic 400s and [FromBody] inference
[ApiController]
[Route("controller/orders")]
public sealed class OrdersController(IOrderStore store) : ControllerBase
{
[HttpPost]
[ProducesResponseType<Order>(StatusCodes.Status201Created)]
public async Task<ActionResult<Order>> Create(CreateOrder cmd, CancellationToken ct)
{
var order = await store.AddAsync(cmd, ct);
return Created($"/controller/orders/{order.Id}", order);
}
}
Program.cs. Why it is wrong: It becomes unreadable and untestable. Instead: One extension method per feature with MapGroup.AddValidation(). Instead: Register validation explicitly and test invalid input.The senior framing is that the choice is a team and consistency decision on top of a shared platform. What actually matters is how endpoints are organised, how validation and errors are standardised (ProblemDetails everywhere), and whether you need AOT or MVC-only features. Migrating an existing healthy controller codebase to Minimal APIs rarely pays back on its own.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| Minimal APIs | New APIs, microservices, AOT, small to large teams with conventions | Must design your own structure | Heavy reliance on MVC filters/formatters |
| Controllers | Existing MVC estates, XML/custom formatters, JSON Patch | More ceremony, no AOT | Scale-to-zero cold-start sensitive services |
| Both in one app | Gradual migration | Two conventions to maintain | As a permanent state without boundaries |
Endpoint routing splits routing into two steps: UseRouting matches the request's path and HTTP method to one endpoint and stores it on HttpContext, and the endpoint middleware at the end executes it. Anything between them, like authorisation, CORS and rate limiting, reads the endpoint's metadata. Routes are defined by templates (/orders/{id:int}, optional and default values, catch-alls {**path}) with constraints that narrow matches. When several routes match, precedence picks the most specific: literals beat parameters, constrained beats unconstrained, catch-alls lose; a true tie throws AmbiguousMatchException. Link generation (LinkGenerator, CreatedAtRoute) builds URLs from route names and values so URLs aren't hard-coded. The trade-off: constraints help disambiguate but are not validation; a failed constraint is a 404, not a 400.
Middleware is a component in the request pipeline: a RequestDelegate that receives the HttpContext, can do work, calls next to pass the request on, and can do more work when the response comes back. It can also short-circuit by not calling next. Use adds middleware that may call next; Run adds terminal middleware; Map branches the pipeline by path; UseWhen branches on a condition and rejoins, MapWhen branches without rejoining. Because each middleware wraps the next, order is behaviour: exception handling first, then HTTPS, static files, routing, CORS, authentication, authorisation and finally endpoints. Custom middleware can be convention-based (a class with InvokeAsync, created once as a singleton) or implement IMiddleware (resolved from DI per request). The trade-off: convention-based is the fastest default; IMiddleware is clearer when you need scoped dependencies.
Last updated 23 Nov 2026.