apis-minimal-and-controllers

Primary docs: - https://learn.microsoft.com/aspnet/core/fundamentals/minimal-apis - https://learn.microsoft.com/aspnet/core/web-api/ - https://learn.microsoft.com/aspnet/core/fundamentals/error-handling-api

APIs: Minimal And Controllers

Primary docs:

First Decision

Choose between:

Do not mix both styles in the same feature unless that split is genuinely useful.

Minimal API Guidance

Prefer Minimal APIs when the surface is small to medium and you want concise endpoint definitions.

Good defaults:

Minimal API reminders:

On .NET 10, Minimal APIs support built-in validation with AddValidation(). Use that instead of inventing parallel validation infrastructure when the target framework supports it.

Controller API Guidance

Prefer controllers when the API needs:

Controller defaults:

Key [ApiController] behaviors:

Shared API Practices

Browser-Facing Notes

Native AOT

Use dotnet new webapiaot only when native AOT is an explicit deployment requirement. Treat it as a constraint that affects library choice, reflection, JSON patterns, and compatibility.