Introduction
FastEndpoints brings structure to ASP.NET APIs by organizing each endpoint as its own class with a clear request, handler, and response. It avoids the ceremony of MVC controllers while providing more structure than Minimal APIs, all with performance on par with raw middleware.
What FastEndpoints Does
- Organizes each API endpoint as a self-contained class following the REPR pattern
- Auto-discovers endpoints at startup with zero manual route registration
- Integrates FluentValidation-style request validation inline
- Provides built-in support for JWT auth, role claims, and permission policies
- Generates OpenAPI/Swagger documentation automatically
Architecture Overview
FastEndpoints sits on top of ASP.NET's routing and middleware pipeline. At startup, it scans assemblies for classes inheriting from Endpoint<TRequest, TResponse> and registers routes. Request binding, validation, and serialization use source generators where possible for minimal reflection. The endpoint class encapsulates HTTP method, route, auth policy, and handler in one place, eliminating the controller-action-attribute ceremony.
Self-Hosting & Configuration
- Install via NuGet:
dotnet add package FastEndpoints - Add
app.UseFastEndpoints()to the ASP.NET pipeline - Configure JSON serialization, versioning, and throttling via fluent builder
- Supports .NET 8 and newer with native AOT compatibility
- Integrates with any ASP.NET middleware (CORS, logging, auth)
Key Features
- REPR pattern: one class per endpoint with typed request and response
- Built-in FluentValidation-compatible request validators
- Pre/post processor pipeline for cross-cutting concerns
- API versioning with header, query, or URL segment strategies
- Sub-millisecond overhead compared to raw Minimal API endpoints
Comparison with Similar Tools
- ASP.NET MVC Controllers — heavier convention with attribute routing; FastEndpoints is leaner per-endpoint
- Minimal APIs — lightweight but can get messy at scale; FastEndpoints adds structure without losing speed
- Carter — similar endpoint-per-class concept; FastEndpoints has more built-in features (validation, auth, versioning)
- Ardalis.ApiEndpoints — MediatR-based approach; FastEndpoints avoids the mediator layer for directness
- NestJS (Node.js) — decorator-based controllers; FastEndpoints achieves similar structure in C# without attributes
FAQ
Q: How does FastEndpoints compare in performance to Minimal APIs? A: Benchmarks show FastEndpoints adds sub-millisecond overhead compared to raw Minimal APIs, making it one of the fastest structured frameworks available.
Q: Can I use FastEndpoints alongside MVC controllers? A: Yes. FastEndpoints registers its own routes and coexists with MVC controllers in the same application.
Q: Does it support Native AOT? A: Yes. FastEndpoints supports .NET Native AOT compilation for reduced startup time and memory footprint.
Q: How do I handle file uploads?
A: Bind IFormFile properties in your request DTO. FastEndpoints handles multipart form data automatically.