ResultCrafter.AspNetCore 3.1.0

dotnet add package ResultCrafter.AspNetCore --version 3.1.0
                    
NuGet\Install-Package ResultCrafter.AspNetCore -Version 3.1.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="ResultCrafter.AspNetCore" Version="3.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ResultCrafter.AspNetCore" Version="3.1.0" />
                    
Directory.Packages.props
<PackageReference Include="ResultCrafter.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 ResultCrafter.AspNetCore --version 3.1.0
                    
#r "nuget: ResultCrafter.AspNetCore, 3.1.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 ResultCrafter.AspNetCore@3.1.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=ResultCrafter.AspNetCore&version=3.1.0
                    
Install as a Cake Addin
#tool nuget:?package=ResultCrafter.AspNetCore&version=3.1.0
                    
Install as a Cake Tool

ResultCrafter.AspNetCore

Return errors. Don't throw them. Turn a Result<T> from your service into the right HTTP response in one call. Errors leave as clean RFC 9457 ProblemDetails, the same shape every time. For .NET 10 and later.

Setup

using ResultCrafter.AspNetCore;

builder.Services.AddResultCrafter();

var app = builder.Build();
app.UseResultCrafter();

Use

The service returns what happened:

public async Task<Result<OrderDto>> GetAsync(int id, CancellationToken ct)
{
    var order = await repo.FindAsync(id, ct);
    if (order is null)
        return Error.NotFound($"Order {id} does not exist.");

    return order.ToDto();
}

The endpoint maps it in one call:

app.MapGet("/orders/{id:int}", async (int id, OrderService orders, CancellationToken ct) =>
    (await orders.GetAsync(id, ct)).ToOkResult());

The client gets 200 with the order, or a 404 like this:

{
  "type": "https://tools.ietf.org/html/rfc9110#section-15.5.5",
  "title": "not_found",
  "status": 404,
  "detail": "Order 42 does not exist.",
  "instance": "/orders/42",
  "traceId": "00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-00",
  "requestId": "0HN8K2MJ7F4QP:00000001"
}

What you get

  • Nine error types with the right status: 400, 401, 403, 404, 409 (conflict and concurrency conflict), 410, 422, and 429 with Retry-After.
  • One ProblemDetails shape for your errors, binding failures, built-in validation and unhandled exceptions.
  • Field errors a client can translate: next to the errors messages, errorCodes carries a code and args for each.
  • Typed success results (200, 201, 202, 204) that OpenAPI sees, and .ProducesNotFound() and friends for the errors.
  • Source-generated logging: 4xx at Warning, 5xx at Error.
  • Minimal APIs first, MVC controllers supported (ResultCrafter.AspNetCore.Mvc).
  • NativeAOT and trim compatible.

Learn more

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

NuGet packages (2)

Showing the top 2 NuGet packages that depend on ResultCrafter.AspNetCore:

Package Downloads
ResultCrafter.AspNetCore.EfCore

EF Core integration for ResultCrafter ASP.NET Core. Maps an optimistic-concurrency DbUpdateConcurrencyException to a 409 RFC 9457 ProblemDetails via IExceptionHandler. Serialization failures and deadlocks (SQLSTATE 40001, 40P01) stay 500.

ResultCrafter.AspNetCore.FluentValidation

FluentValidation endpoint-filter integration for ResultCrafter ASP.NET Core. Adds WithValidation<T>() to validate Minimal API requests with their registered IValidator<T> and short-circuit with an RFC 9457 ProblemDetails 400.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.1.0 96 11/11/2026
3.0.0 119 11/10/2026
2.0.0 12,295 7/7/2026
1.3.0 191 5/27/2026
1.2.0 5,355 4/5/2026
1.1.1 1,069 2/26/2026
1.1.0 150 2/26/2026
1.0.0 145 2/25/2026

Added: field error codes, so a client can show validation errors in its own language. A validation 400 now carries errorCodes next to errors: the same keys, and for each message a { code, args } entry at the same index; errors keeps its exact shape, and errorCodes is left out when no field error has a code or args. New FieldError type (message, optional code, typed args through With) and Error.BadRequest(IReadOnlyDictionary<string, FieldError[]>) for field errors built in a handler; Error.FieldErrors reads them back. ResultCrafter.FluentValidation and WithValidation<T>() fill the code from each failure's ErrorCode (FluentValidation's validator name, such as NotEmptyValidator, when the rule sets none) and the rule's limits as args (minLength, maxLength when the rule has a maximum, from, to, expectedPrecision, expectedScale, and a comparisonValue that is neither a string nor another property); the attempted value is never copied. ProblemResponse documents errorCodes in OpenAPI (new FieldErrorCode schema type). Changed: two validation errors with the same messages but different codes or args are no longer equal. Error.BadRequest(IReadOnlyDictionary<string, string[]>) now throws ArgumentException for a null message instead of sending JSON null, which the errors schema does not allow. Update all ResultCrafter packages together: an older package next to a 3.1 one drops errorCodes and sends the 3.0 body. Guide: https://github.com/HaikAsatryan/ResultCrafter/blob/main/docs/guide.md#field-error-codes