Hlibz.Results.AspNetCore 2.0.0

dotnet add package Hlibz.Results.AspNetCore --version 2.0.0
                    
NuGet\Install-Package Hlibz.Results.AspNetCore -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Hlibz.Results.AspNetCore" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Hlibz.Results.AspNetCore" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Hlibz.Results.AspNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Hlibz.Results.AspNetCore --version 2.0.0
                    
#r "nuget: Hlibz.Results.AspNetCore, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Hlibz.Results.AspNetCore@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Hlibz.Results.AspNetCore&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Hlibz.Results.AspNetCore&version=2.0.0
                    
Install as a Cake Tool

Hlibz.Results.AspNetCore icon

Hlibz.Results.AspNetCore

NuGet CI

Turns Hlibz.Results into HTTP responses with one error body for every failure: from minimal API endpoints and controllers to the authorization gate's own 401/403 and anything your middleware writes.

dotnet add package Hlibz.Results.AspNetCore
builder.Services.AddResultErrorResponses();
builder.Services.AddErrorCodeCatalog(typeof(OrdersErrorCodes).Assembly);

app.MapPost("orders/{id:guid}/lines", async (Guid id, AddLine line, IOrderService orders) =>
    (await orders.AddLineAsync(id, line)).ToHttpResult());

app.MapErrorCodes(); // GET api/error-codes → [{ "code": "orders_1001", "message": "..." }]

Or let handlers return a Result as is: app.MapGroup("/api/orders").WithResultResponses(). In a controller, ToActionResult() sends the same status codes and bodies.

Status HTTP (default)
Success 200
Error 400
Invalid 400
NotFound 404
Unauthorized 401
Forbidden 403
Conflict 409
Unavailable 503

Every failure has this body (validation_errors only when there are any):

{ "message": "The order is closed.", "code": "orders_1001" }

Your code says what failed; the HTTP code is configuration (422 for Invalid, say). Validation error keys follow your JSON naming policy per path segment: Items[0].UnitPrice → items[0].unit_price under snake_case.

For clients that want one shape for every body, success included, there is an opt-in envelope (ToEnvelopeHttpResult(), WithResultEnvelopes(), or your own shape), which can also be sent as HTTP 200 always. The error code catalog publishes every code your app can return, per app if you have several.

AOT-compatible: AddResultErrorResponses adds compile-time JSON metadata for ErrorResponse and ResultEnvelope. In a Native AOT app (reflection-based JSON off), add to your JsonSerializerContext each Result or Result<T> a minimal API handler returns (ASP.NET Core asks for its metadata when it builds the endpoint, even under WithResultResponses()), and the ResultEnvelope<T>s and values you return.

Full documentation and samples: github.com/hlib-zinchenko/Hlibz.Results.

Product 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.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 56 11/18/2026
2.0.0-preview.4 65 11/14/2026
2.0.0-preview.3 49 11/14/2026
2.0.0-preview.2 60 11/13/2026
2.0.0-preview.1 58 11/13/2026
1.1.0 109 11/12/2026
1.0.0 92 11/11/2026