In ASP.NET Core 10, when do controllers still beat Minimal APIs for an HTTP API, and when is a Minimal API the better choice?
answer
- webapi template defaults to Minimal APIs
- --use-controllers flag
- MVC extensibility: binders, validators, application model
- Native AOT rules out MVC
- both can live in one app
basics
~20 sControllers win when you need MVC's extensibility: custom model binders and validators, the filter pipeline, application-model conventions, output-formatter content negotiation, or an existing controller codebase. Minimal APIs win for new services, Native AOT and lower overhead.
solid answer
~40 sIn .NET 10 `dotnet new webapi` generates Minimal APIs unless you pass `--use-controllers`, and Microsoft's docs recommend Minimal APIs for new projects. Controllers still earn their place when you rely on MVC's extension points: `IModelBinderProvider`/`IModelBinder`, `IModelValidator`, application parts and application-model conventions, the five filter kinds, or output formatters negotiating JSON and XML. Big teams also like the class-per-resource structure and the `[ApiController]` conventions. Minimal APIs fit new services and anything published with Native AOT, which MVC does not support, and in .NET 10 they gained built-in validation with `AddValidation()`, closing the last common gap. Both share routing, middleware, DI, authorization and the OpenAPI document, so one app can mix them.
code
bash · 5 lines# Minimal API project (the default)
dotnet new webapi -n Claims.Api
# Controller-based project
dotnet new webapi -n Claims.Api --use-controllersgo deeper
Recall that the webapi template creates Minimal APIs by default and that --use-controllers gives you controllers instead.
Compare the request pipelines: MVC's binders, filters and formatters versus generated delegates, endpoint filters and IResult, and say what each costs.
Make the call per service: Native AOT and small surfaces push to Minimal APIs, MVC extension points and existing code keep controllers, mixing is fine.
Set a portfolio default and a migration rule, so new endpoints follow one style without forcing rewrites of working controller code.
## Same host, two programming models Both styles run on the same ASP.NET Core host: the same middleware pipeline, endpoint routing, dependency injection, authentication and authorization, rate limiting, output caching and the built-in OpenAPI document from `AddOpenApi()`. The difference is how an endpoint is declared and what runs around it. - **Controllers** are classes deriving from `ControllerBase`, registered with `AddControllers()` and mapped with `MapControllers()`. A request goes through MVC's **action invoker**: model binding with model binders, validation into `ModelState`, the authorization, resource, action, exception and result **filters**, and **output formatters** that write the result. - **Minimal APIs** are lambdas or methods mapped with `MapGet`, `MapPost` and friends, often organised with `MapGroup`. Parameters are bound by a generated request delegate, cross-cutting logic runs in **endpoint filters**, and results are `IResult` values from `Results` or `TypedResults`. ## What the template and the docs say in .NET 10 - `dotnet new webapi` has `UseMinimalAPIs` defaulting to `true`; `--use-controllers` (short form `-controllers`) generates a `Controllers/` folder, `AddControllers()` and `MapControllers()` instead. - The ASP.NET Core docs recommend Minimal APIs for new projects and list the reasons to consider controllers: model-binding extensibility (`IModelBinderProvider`, `IModelBinder`), advanced validation (`IModelValidator`), application parts and the application model. They add that most of these can be rebuilt for Minimal APIs, but controllers provide them out of the box. ## When controllers still win | Need | Why controllers fit | |---|---| | Custom model binding for many endpoints | `IModelBinderProvider` plugs into every action; Minimal APIs use `BindAsync`/`TryParse` per type | | Rich validation pipeline | `ModelState`, custom `IModelValidator` providers and the automatic 400 of `[ApiController]` | | Cross-cutting rules by convention | `IApplicationModelConvention`/`IControllerModelConvention` rewrite routes, filters and metadata for whole namespaces | | Content negotiation | output formatters choose JSON or XML from `Accept`; `IResult` types decide their own content type | | Shared behaviour around actions | resource, action, exception and result filters with scope and `Order` | | An existing controller codebase | rewriting working endpoints buys little | Teams with many developers also value the predictable structure: one class per resource, constructor injection, attribute routes next to the code. ## When Minimal APIs win 1. **Native AOT.** The AOT compatibility table lists MVC as not supported; Minimal APIs are supported (partially, with the Request Delegate Generator and a `JsonSerializerContext`). An AOT-published service is a Minimal API service. 2. **Lower overhead.** No controller activation per request and no MVC filter and formatter machinery, which matters for small, high-throughput services. 3. **Small surface.** A microservice with a handful of endpoints reads better as a few `MapGet` lines in a group than as a controller class. 4. **Validation in .NET 10.** `builder.Services.AddValidation()` adds DataAnnotations validation for Minimal API parameters with a generated endpoint filter, removing what used to be the most common reason to stay on controllers. ## Mixing them Nothing forces one choice per application. `AddControllers()` plus `MapControllers()` coexist with `app.MapGroup("/api/v2").MapGet(...)`; both produce endpoints in the same routing table and both appear in the same OpenAPI document. A common migration path keeps existing controllers and writes new endpoints as Minimal APIs, moving shared logic into services so either style can call it. ## A worked decision An insurance company runs a claims platform with forty controller-based endpoints, a custom `IModelBinderProvider` that reads policy numbers in several legacy formats, and XML output for one partner. A new document-upload service is being added that must start fast in containers and could be published with Native AOT. A sound plan keeps the claims API on controllers, because the binder and the XML formatter are MVC features it relies on, and builds the upload service as a Minimal API, where AOT is possible and the surface is small. Neither team rewrites the other's code, and both still share authentication, OpenAPI and observability conventions. ## How to answer in an interview Show that the choice is about **features you depend on**, not taste: - name the MVC extension points you would miss; - name Native AOT as the hard constraint the other way; - mention that both styles share hosting, routing, auth and OpenAPI, so the decision is per endpoint, not per platform; - avoid claiming that Minimal APIs are only for prototypes, or that controllers are deprecated; neither is true in .NET 10.
- Is MVC deprecated in favour of Minimal APIs?No. Controllers are fully supported in ASP.NET Core 10, the `webapi` template still generates them with `--use-controllers`, and the `mvc` template is unchanged. Microsoft recommends Minimal APIs for new projects, which is a default, not a deprecation.
- Which part of a controller codebase is hardest to port to Minimal APIs?Whatever relies on MVC-only extension points: custom `IModelBinderProvider` binders, `IModelValidator` validators, application-model conventions and resource or result filters. Each needs an equivalent such as `BindAsync`, endpoint filters or group conventions, so port those first or keep those endpoints as controllers.
- Controllers are deprecated in .NET 10 and the webapi template can no longer create them.
- Minimal APIs cannot use authorization, DI or OpenAPI the way controllers do.
- A single ASP.NET Core app must choose either controllers or Minimal APIs.
- An MVC controller app can be published with Native AOT like a Minimal API.
- Minimal APIs still have no built-in validation in .NET 10.
Assumes ASP.NET Core 10: the webapi template defaults to Minimal APIs (controllers via --use-controllers), Minimal APIs gained built-in validation with AddValidation(), and MVC remains unsupported under Native AOT.