DKNet.AspCore.Extensions
Endpoint discovery, request binding and HTTP helpers for .NET developers building DKNet minimal APIs.
β¨ Why use it?
- Map feature-owned route groups with consistent version and policy metadata.
- Populate host-controlled request members before validation.
- Dispatch commands or entity queries and return consistent result envelopes.
- Compose explicit middleware for host transport and request guards.
π Quick Start
Use a .NET 10 ASP.NET Core project.
dotnet new web -f net10.0 -n PackageDemo
cd PackageDemo
dotnet add package DKNet.AspCore.Extensions
Replace Program.cs with the example, then run dotnet run.
using DKNet.AspCore.Extensions;
using DKNet.AspCore.Extensions.Endpoints;
using Microsoft.AspNetCore.Routing;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.UseEndpointConfigs(o =>
{
o.EnableVersioning = false;
o.RequireAuthorization = false;
}, typeof(PingEndpoints).Assembly);
await app.RunAsync();
public sealed class PingEndpoints : IEndpointConfig
{
public string GroupEndpoint => "/ping";
public void Map(RouteGroupBuilder group) => group.MapGet("/", () => "pong");
}
Request GET /ping/ to see pong. This local example explicitly disables versioning and authorization. Normal defaults require AddApiVersioning() and host authentication/authorization setup.
ποΈ Architecture

These helpers run inside the consumerβs ASP.NET Core process. Contextual resolvers are scoped; the host supplies authentication, authorization policies, bus handlers, repository configuration and external databases. Middleware helpers use keyed registration markers; MarkFeatureAdded and IsFeatureAdded are public marker utilities, not middleware execution.
π How it works

Versioning is enabled by default and checked before discovery. The Quick Start opts out explicitly. A declared contextual member requires population registration and a setter; missing setup fails when endpoint metadata is built.
π§© Features
- Discover and map endpoint groups β Discover groups and choose versioned routes and authorization policies.
- Populate request members from context β Overwrite bound members from claims, headers, or custom host sources.
- Dispatch HTTP requests through SlimMessageBus β Choose command/query mappers and understand their binding and HTTP results.
- Read and delete entities through specifications β Read, list, and hard-delete through the specification repository.
- Filter, search and page list endpoints β Validate filters, search, ordering, page sizes, and activity windows.
- Build a paged response envelope β Snapshot an existing page into a response envelope.
- Convert FluentResults to HTTP results β Convert success and failure results into minimal-API responses.
- Apply one error-response setting β Apply shared status and body callbacks to command, validation, and exception failures.
- Configure generated CRUD routes β Exclude generated routes and attach settings by kind or route name.
- Configure an explicit CORS policy β Install a browser policy for explicit allowed origins.
- Configure trusted forwarding sources β Accept forwarded scheme and client IP only from configured sources.
- Configure HSTS and HTTPS redirection β Register HSTS settings and install HTTPS redirection.
- Bound request size and duration β Configure Kestrel size limits and a default timeout policy.
- Limit rate and concurrent requests β Partition local request-rate and concurrency limits.
- Validate antiforgery headers on browser mutations β Issue request-token cookies and validate headers on checked mutations.
- Resolve the current principal for sensitive-data serialization β Supply the current HTTP principal to sensitive-data serialization.
- Select a named job from command-line arguments β Match a positional argument to a known job name without executing it.