ASP.NET Core Web API runs each HTTP request through a middleware pipeline, then dispatches it to an endpoint (a Minimal API handler or a controller action). In practice, you design a Web API by choosing where logic lives (middleware vs filters vs endpoint code), how you validate and map inputs, and how you handle errors and auth. This matters because most production issues come from cross-cutting concerns: auth, validation, versioning, serialization, and observability.

Request Flow

sequenceDiagram
  participant Client
  participant Middleware
  participant Routing
  participant Endpoint

  Client->>Middleware: Request
  Middleware->>Routing: Route match
  Routing->>Endpoint: Invoke
  Endpoint->>Middleware: Result
  Middleware->>Client: Response

Endpoint Examples

Minimal API:

var app = WebApplication.CreateBuilder(args).Build();
 
app.MapGet("/health", () => Results.Ok(new { status = "ok" }));
 
app.Run();

Controller style:

[ApiController]
[Route("api/orders")]
public sealed class OrdersController : ControllerBase
{
    [HttpGet("{id}")]
    public ActionResult<OrderDto> GetById(string id) => Ok(new OrderDto(id));
}

Questions

References

6 items under this folder.