Nestgrid.Response.AspNetCore 0.8.0

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

Nestgrid.Response.AspNetCore

ASP.NET Core adapters for converting Nestgrid results into Minimal API and controller responses.

Nestgrid.Response.AspNetCore adds ToIResult() and ToActionResult() adapters backed by the shared HTTP mapping policy in Nestgrid.Response.Http.

Installation

dotnet add package Nestgrid.Response.AspNetCore

Quick Start

using Nestgrid.Response;
using Nestgrid.Response.AspNetCore.Extensions;

builder.Services.AddNestgridResponse();

app.MapGet("/users/{id:int}", (int id, UserService users) =>
{
    Result<UserDto> result = users.Get(id);

    return result.ToIResult();
});

AddNestgridResponse() is optional when the built-in defaults are sufficient. Register it when you want global response options.

Realistic Example

using Nestgrid.Response;
using Nestgrid.Response.AspNetCore.Extensions;
using Nestgrid.Response.Http.Options;

builder.Services.AddNestgridResponse(options =>
{
    options.SuccessResponseMode = SuccessResponseMode.ValueOnly;
});

app.MapPost("/users", (CreateUserRequest request, UserService users) =>
{
    Result<UserDto> result = users.Create(request);

    return result.ToIResult();
});

For a single endpoint, pass options directly:

var options = new NestgridResponseOptions
{
    SuccessResponseMode = SuccessResponseMode.ValueOnly
};

return result.ToIResult(options);

Feature Summary

  • Converts Result and Result<T> to Minimal API IResult.
  • Converts Result and Result<T> to MVC IActionResult.
  • Supports global and per-call NestgridResponseOptions.
  • Uses shared HTTP mapping from Nestgrid.Response.Http.
  • Supports FullResult and ValueOnly success payload modes.
  • Suppresses response bodies for ResultStatus.NoContent.

SuccessResponseMode

FullResult is the default. It serializes the result envelope:

{
  "value": {
    "id": 1,
    "name": "Ada"
  },
  "messages": []
}

ValueOnly serializes only the value for successful generic results:

{
  "id": 1,
  "name": "Ada"
}

Failures always write the result envelope. NoContent results never write a response body.

Custom Status Mappings

Override mappings globally:

builder.Services.AddNestgridResponse(options =>
{
    options.StatusMappings[ResultStatus.Failed] =
        StatusCodes.Status400BadRequest;
});

Default mappings:

Result status HTTP status
Ok 200
Created 201
Accepted 202
NoContent 204
Invalid 400
Unauthorized 401
Forbidden 403
NotFound 404
Conflict 409
Cancelled 409
Failed 422
Error 500

Custom mappings are consumer-owned security configuration. Preserve the defaults for Unauthorized, Forbidden, Error and NoContent unless the integration has explicitly reviewed the authentication, authorisation, caching and client-control consequences.

Mapping Results

Map application results before converting them to HTTP responses:

using Nestgrid.Response.Extensions;

app.MapGet("/users/{id:int}", (int id, UserService users) =>
{
    return users.GetDomainUser(id)
        .Map(user => new UserDto(user!.Id, user.Name))
        .ToIResult();
});

Map() only executes for successful results. Non-success statuses preserve their status and messages and bypass the mapper.

OpenAPI Guidance

The package converts responses at runtime but does not add OpenAPI metadata. Declare response status codes and payload types on each endpoint.

For FullResult:

app.MapGet("/users/{id:int}", GetUser)
    .Produces<Result<UserDto>>(StatusCodes.Status200OK)
    .Produces<Result<UserDto>>(StatusCodes.Status404NotFound);

For ValueOnly, describe successful responses with the value type and failures with the result type:

app.MapGet("/users/{id:int}", GetUser)
    .Produces<UserDto>(StatusCodes.Status200OK)
    .Produces<Result<UserDto>>(StatusCodes.Status404NotFound);

Document 204 No Content without a response type.

Documentation

Samples

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 was computed.  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

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
0.8.0 82 8/28/2026
0.7.0 100 8/18/2026
0.6.0 113 7/20/2026
0.5.0 128 6/26/2026