Free course · 11 lessons · Intermediate
ASP.NET Core Web APIs
Build ASP.NET Core Web APIs on .NET 10 that hold up in production: minimal APIs with route groups and typed results, built-in validation, dependency injection lifetimes, ProblemDetails errors, filters and middleware, validated options, authentication and authorization policies, EF Core with optimistic concurrency, integration tests with TestServer, and output caching, rate limiting and health checks. Every example is a real ASP.NET Core app, built and called over HTTP.
1. Minimal APIs Done Right
Endpoints and route groups, built-in validation, dependency injection lifetimes, ProblemDetails errors, and filters and middleware.
- Minimal APIs, Route Groups and Typed Results — Build a JSON API with ASP.NET Core minimal APIs: route groups, route parameters, TypedResults and correct status codes.
- Built-in Validation for Minimal APIs — Validate request bodies with data annotations and .NET 10's built-in minimal API validation, returning ProblemDetails errors.
- Dependency Injection Lifetimes and Captive Dependencies — Register services as singleton, scoped or transient, and avoid the captive dependency bug where a singleton holds a scoped service.
- Consistent Errors with ProblemDetails and IExceptionHandler — Turn exceptions into ProblemDetails responses with UseExceptionHandler and IExceptionHandler, mapping domain errors to the right status.
- Endpoint Filters and Middleware — Add cross-cutting behaviour with middleware for every request and endpoint filters for specific endpoints, in the right order.
2. Configuration, Security, Data and Operations
Validated options, authentication and authorization policies, EF Core with concurrency control, integration tests, and caching, rate limiting and health checks.
- Validated Options and Fail-Fast Configuration — Bind configuration to typed options, validate it with data annotations and ValidateOnStart, and choose between IOptions, IOptionsSnapshot and IOptionsMonitor.
- Authentication Schemes and Authorization Policies — Authenticate callers with an authentication handler, authorize with policies and requirements, and return 401 versus 403 correctly.
- EF Core: Queries, Projections and Optimistic Concurrency — Use EF Core with a scoped DbContext, project queries to DTOs without N+1, and handle concurrent updates with concurrency tokens.
- Integration Tests with TestServer — Test the whole HTTP pipeline in memory with TestServer, replacing dependencies such as the clock and external services.
- Output Caching, Rate Limiting and Health Checks — Cache GET responses with output caching, protect endpoints with the rate limiter, and expose liveness and readiness health checks.
3. Capstone
Design a production ASP.NET Core API.
- Capstone: A Booking API in ASP.NET Core — Design an ASP.NET Core API for clinic appointment booking: structure, validation, auth, data consistency, testing and operations.