FunctionalDdd.Asp 2.1.10

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package FunctionalDdd.Asp --version 2.1.10
                    
NuGet\Install-Package FunctionalDdd.Asp -Version 2.1.10
                    
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="FunctionalDdd.Asp" Version="2.1.10" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FunctionalDdd.Asp" Version="2.1.10" />
                    
Directory.Packages.props
<PackageReference Include="FunctionalDdd.Asp" />
                    
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 FunctionalDdd.Asp --version 2.1.10
                    
#r "nuget: FunctionalDdd.Asp, 2.1.10"
                    
#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 FunctionalDdd.Asp@2.1.10
                    
#: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=FunctionalDdd.Asp&version=2.1.10
                    
Install as a Cake Addin
#tool nuget:?package=FunctionalDdd.Asp&version=2.1.10
                    
Install as a Cake Tool

ASP Extension

This library will help convert Error objects to ASP.NET Core ActionResult

MVC

ToActionResult

Use this method to convert Result to OkObjectResult or various failed results.

It supports pagination by passing three parameters to, from and length. Based on the values it will return PartialContent (206) or Okay(200) per RFC9110

Failed state is based on the Error object. The mapping is as follows

    NotFoundError => (ActionResult<T>)controllerBase.NotFound(error),
    ValidationError validation => ValidationErrors<T>(validation, controllerBase),
    ConflictError => (ActionResult<T>)controllerBase.Conflict(error),
    UnauthorizedError => (ActionResult<T>)controllerBase.Unauthorized(error),
    ForbiddenError => (ActionResult<T>)controllerBase.StatusCode(StatusCodes.Status403Forbidden, error),
    UnexpectedError => (ActionResult<TValue>)controllerBase.StatusCode(StatusCodes.Status500InternalServerError, error),
    _ => (ActionResult<TValue>)controllerBase.StatusCode(StatusCodes.Status500InternalServerError, error),

MVC Example

Simple case.

[HttpPost("[action]")]
public ActionResult<User> Register([FromBody] RegisterRequest request) =>
    FirstName.TryCreate(request.firstName)
    .Combine(LastName.TryCreate(request.lastName))
    .Combine(EmailAddress.TryCreate(request.email))
    .Bind((firstName, lastName, email) => SampleWebApplication.User.TryCreate(firstName, lastName, email, request.password))
    .ToActionResult(this);

To control the return type

[HttpPost("[action]")]
public ActionResult<User> RegisterCreated2([FromBody] RegisterRequest request) =>
    FirstName.TryCreate(request.firstName)
    .Combine(LastName.TryCreate(request.lastName))
    .Combine(EmailAddress.TryCreate(request.email))
    .Bind((firstName, lastName, email) => SampleWebApplication.User.TryCreate(firstName, lastName, email, request.password))
    .Finally(
        ok => CreatedAtAction("Get", new { name = ok.FirstName }, ok),
        err => err.ToErrorActionResult<User>(this));

Minimal API

ToHttpResult

Use this method to convert Result to Http.IResult or various failed results.

Minimal API Example

Simple case.

userApi.MapPost("/register", (RegisterUserRequest request) =>
    FirstName.TryCreate(request.firstName)
    .Combine(LastName.TryCreate(request.lastName))
    .Combine(EmailAddress.TryCreate(request.email))
    .Bind((firstName, lastName, email) => User.TryCreate(firstName, lastName, email, request.password))
    .ToHttpResult());

To control the return type

userApi.MapPost("/registerCreated", (RegisterUserRequest request) =>
    FirstName.TryCreate(request.firstName)
    .Combine(LastName.TryCreate(request.lastName))
    .Combine(EmailAddress.TryCreate(request.email))
    .Bind((firstName, lastName, email) => User.TryCreate(firstName, lastName, email, request.password))
    .Map(user => new RegisterUserResponse(user.Id, user.FirstName, user.LastName, user.Email, user.Password))
    .Finally(
            ok => Results.CreatedAtRoute("GetUserById", new RouteValueDictionary { { "name", ok.firstName } }, ok),
            err => err.ToErrorResult()));
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
3.0.0-alpha.44 6 1/13/2026
3.0.0-alpha.20 42 1/6/2026
3.0.0-alpha.19 42 1/5/2026
3.0.0-alpha.13 40 1/5/2026
3.0.0-alpha.9 39 1/5/2026
3.0.0-alpha.3 146 12/20/2025
2.1.10 676 12/3/2025
2.1.9 267 11/21/2025
2.1.1 235 4/26/2025
2.1.0-preview.3 130 4/26/2025
2.0.1 225 1/23/2025
2.0.0-alpha.62 82 1/8/2025
2.0.0-alpha.61 89 1/7/2025
2.0.0-alpha.60 104 12/7/2024
2.0.0-alpha.55 88 11/22/2024
2.0.0-alpha.52 95 11/7/2024
2.0.0-alpha.48 83 11/2/2024
2.0.0-alpha.47 103 10/30/2024
2.0.0-alpha.44 159 10/18/2024
2.0.0-alpha.42 109 10/14/2024
2.0.0-alpha.39 126 6/27/2024
2.0.0-alpha.38 109 4/24/2024
2.0.0-alpha.33 99 4/17/2024
2.0.0-alpha.26 157 4/9/2024
2.0.0-alpha.21 120 4/1/2024
2.0.0-alpha.19 110 3/5/2024
2.0.0-alpha.18 104 2/28/2024
2.0.0-alpha.17 96 2/26/2024
2.0.0-alpha.15 131 1/30/2024
2.0.0-alpha.8 98 1/27/2024
2.0.0-alpha.6 172 1/5/2024
1.1.1 666 11/15/2023
1.1.0-alpha.32 191 11/2/2023
1.1.0-alpha.30 253 10/31/2023
1.1.0-alpha.28 153 10/28/2023
1.1.0-alpha.27 126 10/28/2023
1.1.0-alpha.24 125 10/20/2023
1.1.0-alpha.23 127 10/13/2023
1.1.0-alpha.22 130 10/13/2023
1.1.0-alpha.21 154 10/1/2023
1.1.0-alpha.20 137 9/30/2023
1.1.0-alpha.19 149 9/30/2023
1.1.0-alpha.18 166 9/29/2023
1.1.0-alpha.17 127 9/22/2023
1.1.0-alpha.13 132 9/16/2023
1.1.0-alpha.4 225 6/9/2023
1.1.0-alpha.3 162 6/8/2023
1.0.1 770 5/12/2023
0.1.0-alpha.40 218 4/6/2023
0.1.0-alpha.39 216 4/3/2023
0.1.0-alpha.38 253 4/2/2023
0.1.0-alpha.37 231 3/31/2023
0.1.0-alpha.35 223 3/29/2023
0.1.0-alpha.34 198 3/28/2023
0.1.0-alpha.32 244 3/18/2023
0.1.0-alpha.30 233 3/11/2023
0.1.0-alpha.27 274 3/7/2023
0.1.0-alpha.24 258 2/15/2023
0.1.0-alpha.22 228 2/15/2023
0.1.0-alpha.20 235 2/13/2023
0.1.0-alpha.19 175 2/13/2023
0.0.1-alpha.14 244 1/4/2023
0.0.1-alpha.4 226 12/30/2022
0.0.1-alpha.3 253 12/23/2022
0.0.1-alpha 683 12/21/2022