KrzysKlein.ResultDotNet.AspNetCore
0.3.0
dotnet add package KrzysKlein.ResultDotNet.AspNetCore --version 0.3.0
NuGet\Install-Package KrzysKlein.ResultDotNet.AspNetCore -Version 0.3.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="KrzysKlein.ResultDotNet.AspNetCore" Version="0.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="KrzysKlein.ResultDotNet.AspNetCore" Version="0.3.0" />
<PackageReference Include="KrzysKlein.ResultDotNet.AspNetCore" />
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 KrzysKlein.ResultDotNet.AspNetCore --version 0.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: KrzysKlein.ResultDotNet.AspNetCore, 0.3.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 KrzysKlein.ResultDotNet.AspNetCore@0.3.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=KrzysKlein.ResultDotNet.AspNetCore&version=0.3.0
#tool nuget:?package=KrzysKlein.ResultDotNet.AspNetCore&version=0.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ResultDotNet.AspNetCore
Extensions for using the Result Pattern in ASP.NET Core applications.
Overview
ResultDotNet.AspNetCore provides helpers and extension methods to integrate the Result Pattern with ASP.NET Core, making it easier to handle errors, map results to HTTP responses, and compose functional pipelines in web APIs.
Installation
Add the package via NuGet:
# .NET CLI
dotnet add package KrzysKlein.ResultDotNet.AspNetCore
Basic Usage
Mapping Results to HTTP Responses
public IActionResult MyAction()
{
var result = SomeService.DoSomething();
return result.ToActionResult();
}
Asynchronous Results
public async Task<IActionResult> MyAsyncAction()
{
var result = await SomeService.DoSomethingAsync();
return result.ToActionResult();
}
Custom Error Mapping
You can map errors to custom ProblemDetails or other response types using provided extension methods.
API Overview
ToActionResult(): Converts aResult<ProblemDetails>, orResult<TValue, ProblemDetails>, orValueResult<ProblemDetails>orValueResult<TValue, ProblemDetails>to anIActionResult.- Extensions for handling
Task<Result<...>>orTask<ValueResult<...>>in async controller actions. - Helpers for mapping errors to
ProblemDetails.
Examples
See examples for usage in real ASP.NET Core APIs.
License
MIT License
Links
| Product | Versions 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.
-
net10.0
- KrzysKlein.ResultDotNet (>= 0.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.