DotEmilu.AspNetCore
10.0.0
Prefix Reserved
dotnet add package DotEmilu.AspNetCore --version 10.0.0
NuGet\Install-Package DotEmilu.AspNetCore -Version 10.0.0
<PackageReference Include="DotEmilu.AspNetCore" Version="10.0.0" />
<PackageVersion Include="DotEmilu.AspNetCore" Version="10.0.0" />
<PackageReference Include="DotEmilu.AspNetCore" />
paket add DotEmilu.AspNetCore --version 10.0.0
#r "nuget: DotEmilu.AspNetCore, 10.0.0"
#:package DotEmilu.AspNetCore@10.0.0
#addin nuget:?package=DotEmilu.AspNetCore&version=10.0.0
#tool nuget:?package=DotEmilu.AspNetCore&version=10.0.0
DotEmilu.AspNetCore
ASP.NET Core integration for DotEmilu — bridges use-case handlers to Minimal API endpoints, formats errors as RFC 7807 Problem Details, and provides AsDelegate for zero-boilerplate endpoint wiring.
Install
dotnet add package DotEmilu.AspNetCore
This transitively installs DotEmilu and DotEmilu.Abstractions.
What's included
HTTP handlers
| Type | Purpose |
|---|---|
HttpHandler<TRequest> |
Wraps IHandler<TRequest> — executes handler, checks validation, returns IResult |
HttpHandler<TRequest, TResponse> |
Wraps IHandler<TRequest, TResponse> — same, but with a typed response payload |
Delegate helpers
| Type | Purpose |
|---|---|
AsDelegate.ForAsync<TRequest>() |
Converts a handler into a Func<TRequest, HttpHandler, CancellationToken, Task<IResult>> for Minimal API |
AsDelegate.ForAsync<TRequest, TResponse>() |
Same, for handlers with a response |
Presenter
| Type | Purpose |
|---|---|
IPresenter |
Interface for formatting HTTP responses (Success, ValidationError, ServerError) |
Presenter (internal) |
Default implementation: returns ValidationProblem (400) and Problem (500) using RFC 7807, with dev-mode stack traces |
Configuration
| Type | Purpose |
|---|---|
ResultMessage |
Options class bound to appsettings.json section "ResultMessage" — defines titles and details for validation/server errors |
DI registration
| Method | Purpose |
|---|---|
services.AddDotEmilu() |
Registers IVerifier<>, HttpHandler<>, HttpHandler<,>, IPresenter, and binds ResultMessage from configuration |
Endpoint wiring with AsDelegate
The cleanest way to define endpoints — no handler variable, no manual HandleAsync call:
var invoices = app.MapGroup("/invoices");
// POST /invoices → 201 Created
invoices.MapPost("", AsDelegate.ForAsync<CreateInvoiceRequest>(TypedResults.Created));
// GET /invoices → 200 OK with PaginatedList<Invoice>
invoices.MapGet("", AsDelegate.ForAsync<GetInvoicesRequest, PaginatedList<Invoice>>());
// GET /invoices/{id} → 200 OK or 404 Not Found
invoices.MapGet("{id:int}", AsDelegate.ForAsync<GetInvoiceByIdRequest, InvoiceResponse>(
response => response is null ? TypedResults.NotFound() : TypedResults.Ok(response)));
// PUT /invoices/{id} → 204 No Content
invoices.MapPut("{id:int}", AsDelegate.ForAsync<UpdateInvoiceRequest>(TypedResults.NoContent));
// DELETE /invoices/{id} → 204 No Content
invoices.MapDelete("{id:int}", AsDelegate.ForAsync<DeleteInvoiceRequest>(TypedResults.NoContent));
Manual HttpHandler usage
If you need more control, inject HttpHandler directly:
app.MapPost("/invoices", async (
CreateInvoiceRequest request,
HttpHandler<CreateInvoiceRequest> handler,
CancellationToken ct) =>
await handler.HandleAsync(request, ct, () => TypedResults.Created()));
Configuration
Add to appsettings.json:
{
"ResultMessage": {
"ValidationError": {
"Title": "Bad Request",
"Detail": "One or more validation errors occurred."
},
"ServerError": {
"Title": "Internal Server Error",
"Detail": "An unexpected error occurred. Please contact the administrator."
}
}
}
Full registration
builder.Services
.AddDotEmilu() // HttpHandler + Presenter + Verifier
.AddHandlers(Assembly.GetExecutingAssembly()) // scan handlers
.AddChainHandlers(Assembly.GetExecutingAssembly()) // scan chain handlers
.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly()); // FluentValidation validators
Additional documentation
Part of the DotEmilu ecosystem
| Package | Description |
|---|---|
| DotEmilu.Abstractions | Core interfaces and base classes |
| DotEmilu | Handler pipeline with FluentValidation |
| DotEmilu.AspNetCore (this) | ASP.NET Core Minimal API integration |
| DotEmilu.EntityFrameworkCore | EF Core interceptors and configurations |
Feedback
File bugs, feature requests, or questions on GitHub Issues.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- DotEmilu (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.