Table of Contents

Class ApplicationBuilderExtensions

Namespace
Trellis.Asp
Assembly
Trellis.Asp.dll

IApplicationBuilder extensions for Trellis ASP.NET integration.

public static class ApplicationBuilderExtensions
Inheritance
ApplicationBuilderExtensions
Inherited Members

Methods

UseTrellisProblemDetails(IApplicationBuilder)

Wires the canonical Trellis ProblemDetails pipeline so unhandled exceptions and ASP.NET status-code short-circuits (404 / 405 / 415 / 5xx) become RFC 9457 ProblemDetails responses with the enrichment registered by AddTrellisProblemDetails(IServiceCollection).

public static IApplicationBuilder UseTrellisProblemDetails(this IApplicationBuilder app)

Parameters

app IApplicationBuilder

The application builder.

Returns

IApplicationBuilder

The application builder for chaining.

Examples

var app = builder.Build();
app.UseTrellisProblemDetails();
app.UseRouting();
app.MapControllers();
app.Run();

Remarks

Equivalent to calling app.UseExceptionHandler() followed by app.UseStatusCodePages(). The first catches unhandled exceptions and rewrites them to 500 ProblemDetails; the second catches empty-body status-code responses (404 from a route miss, 405 from a method mismatch, 415 from a content-type mismatch) and rewrites them to ProblemDetails bodies.

Ordering. Register this early in the pipeline, before UseRouting / endpoint middleware. UseStatusCodePages only rewrites status-code responses that come from downstream middleware, so it must be registered before any middleware that could emit one.