Vostra.Result.AspNetCore 1.2.1

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

Vostra.Result.AspNetCore

ASP.NET Core HTTP mapping for Vostra.Result: turn a Result/Result<T> into an HTTP response with one extension method. Works in minimal APIs and MVC controllers — no base class.

Install

dotnet add package Vostra.Result.AspNetCore

Setup (optional)

The whole point: your error kinds already know what they mean, so the HTTP layer shouldn't repeat that in a central switch. ToHttpResponse reads the status from the error itself and works with sensible defaults out of the box — call AddVostraResults only when you want to override the map:

builder.Services.AddVostraResults(o =>
{
    o.MapStatus(ErrorType.Conflict, 422);        // override a whole ErrorType
    o.MapStatusForCode("Order.Locked", 423);     // override one error code
});

Precedence: per-Code override → per-ErrorType map → built-in default.

ErrorType Default status
Validation 400
Unauthorized 401
Forbidden 403
NotFound 404
Conflict 409
Unexpected 500

A new ErrorBase subclass maps automatically through its ErrorType — no mapping edits.

Usage

Endpoints stay one line — return the Result and let the mapping pick the status, body, and pagination. Same call in minimal APIs and controllers, no base class:

// minimal API
app.MapGet("/orders/{id}", (int id, HttpContext http, IOrderService svc) =>
    svc.Get(id).ToHttpResponse(http));

// controller
[HttpGet("{id}")]
public async Task<IResult> Get(int id) =>
    (await _svc.Get(id)).ToHttpResponse(HttpContext);

// paginated list
app.MapGet("/orders", (HttpContext http, IOrderService svc) =>
    svc.List().ToHttpResponse(http, new Pagination(page: 1, pageSize: 20, totalCount: 137)));

Wire shapes

Success bodies stay thin (just a correlation id + your data); failures are standard ProblemDetails that keep the error's identity on the wire — which is exactly what lets the testing package reconstruct the typed error later.

Success (SuccessKind.Ok → 200, Created → 201):

{ "operationId": "00-abc…-01", "data": { "id": 42 } }

List:

{ "operationId": "…", "data": [ … ],
  "pagination": { "page": 1, "pageSize": 20, "totalCount": 137, "totalPages": 7 } }

Error — RFC 7807 application/problem+json, carrying code + errorType so a test client can assert on typed-error identity:

{ "type": "about:blank", "title": "Not Found", "status": 404,
  "detail": "Order 42 not found", "code": "Order.NotFound", "errorType": "NotFound",
  "operationId": "…" }

Validation errors (all ErrorType.Validation) render a field → messages map (field key = metadata["field"] if present, else the error Code):

{ "status": 400, "code": "General.Validation", "errorType": "Validation",
  "errors": { "Sku": ["required"], "Price": ["must be > 0"] }, "operationId": "…" }

Migration from a { status, operationId, data } envelope

  • Success bodies drop status (read the HTTP status line); error bodies keep it (RFC 7807).
  • operationId is a W3C trace id (Activity.Current?.Id ?? HttpContext.TraceIdentifier).
  • Lists use ToHttpResponse(http, Pagination) with this package's Pagination record.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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 (1)

Showing the top 1 NuGet packages that depend on Vostra.Result.AspNetCore:

Package Downloads
Vostra.Result.AspNetCore.Testing

HTTP integration-testing toolkit for Vostra.Result — a TestHttpClient returning Result<T> with typed-error reconstruction over the Vostra.Result.AspNetCore response contract.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.1 138 7/5/2026
1.2.0 142 7/4/2026
1.1.3 154 6/26/2026
1.1.2 165 6/26/2026
1.1.1 138 6/26/2026