MaksIT.Results
2.0.1
dotnet add package MaksIT.Results --version 2.0.1
NuGet\Install-Package MaksIT.Results -Version 2.0.1
<PackageReference Include="MaksIT.Results" Version="2.0.1" />
<PackageVersion Include="MaksIT.Results" Version="2.0.1" />
<PackageReference Include="MaksIT.Results" />
paket add MaksIT.Results --version 2.0.1
#r "nuget: MaksIT.Results, 2.0.1"
#:package MaksIT.Results@2.0.1
#addin nuget:?package=MaksIT.Results&version=2.0.1
#tool nuget:?package=MaksIT.Results&version=2.0.1
MaksIT.Results
MaksIT.Results is a .NET library for modeling operation outcomes as HTTP-aware result objects and converting them to IActionResult in ASP.NET Core.
Features
ResultandResult<T>models with status code, success flag, and messages.- Static factory methods for common and extended HTTP status codes (1xx, 2xx, 3xx, 4xx, 5xx).
- Built-in conversion to
IActionResultviaToActionResult(). - RFC 7807-style error payloads for failures (
application/problem+json). - Camel-case JSON serialization for response bodies; respects app-configured
JsonSerializerOptions(e.g.AddJsonOptionswithDefaultIgnoreCondition.WhenWritingNull).
Installation
Package Manager:
Install-Package MaksIT.Results
dotnet CLI:
dotnet add package MaksIT.Results
Target Framework
.NET 10(net10.0)
Quick Start
Create results
using MaksIT.Results;
Result ok = Result.Ok("Operation completed");
Result failed = Result.BadRequest("Validation failed");
Result<int> okWithValue = Result<int>.Ok(42, "Answer generated");
Result<string?> notFound = Result<string?>.NotFound(null, "Entity not found");
Convert between result types
using MaksIT.Results;
Result<int> source = Result<int>.Ok(42, "Value loaded");
// Result<T> -> Result<U>
Result<string?> mapped = source.ToResultOfType(v => v?.ToString());
// Result<T> -> Result
Result nonGeneric = source.ToResult();
Use in an ASP.NET Core controller
using MaksIT.Results;
using Microsoft.AspNetCore.Mvc;
public sealed class UsersController : ControllerBase {
[HttpGet("{id:guid}")]
public IActionResult GetUser(Guid id) {
Result<UserDto?> result = id == Guid.Empty
? Result<UserDto?>.BadRequest(null, "Invalid id")
: Result<UserDto?>.Ok(new UserDto(id, "maks"), "User loaded");
return result.ToActionResult();
}
}
public sealed record UserDto(Guid Id, string Name);
ToActionResult() Behavior
Resultsuccess: returns status-code-only response.Result<T>success with non-nullValue: returns JSON body + status code.- Any failure: returns RFC 7807-style
ProblemDetailsJSON with:status= result status codetitle="An error occurred"detail= joinedMessages- content type
application/problem+json
JSON options
ObjectResult uses the same JsonSerializerOptions as your app when you configure them with AddJsonOptions:
builder.Services.AddControllers()
.AddJsonOptions(options => {
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
});
If no options are registered, a default (camel-case) serializer is used.
Status Code Factories
- Informational:
Result.Continue(...),Result.SwitchingProtocols(...),Result.Processing(...), etc. - Success:
Result.Ok(...),Result.Created(...),Result.NoContent(...), etc. - Redirection:
Result.Found(...),Result.PermanentRedirect(...), etc. - Client error:
Result.BadRequest(...),Result.NotFound(...),Result.TooManyRequests(...), etc. - Server error:
Result.InternalServerError(...),Result.ServiceUnavailable(...), etc.
Generic equivalents are available via Result<T>, for example Result<MyDto>.Ok(value, "message").
Contributing
See CONTRIBUTING.md.
Contact
If you have any questions or need further assistance, feel free to reach out:
- Email: maksym.sadovnychyy@gmail.com
- Reddit: MaksIT.Results: Streamline Your ASP.NET Core API Response Handling
License
See LICENSE.md.
| 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. |
-
net10.0
- Microsoft.AspNetCore.Mvc.Abstractions (>= 2.3.9)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Options (>= 10.0.3)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on MaksIT.Results:
| Package | Downloads |
|---|---|
|
MaksIT.MongoDB.Linq
MaksIT.MongoDB.Linq is a .NET library designed to facilitate working with MongoDB using LINQ queries, providing a seamless and intuitive interface for developers to interact with MongoDB databases. The library abstracts common data access patterns, allowing for more efficient and readable code when performing CRUD operations, managing sessions, and handling transactions. |
|
|
MaksIT.Dapr
MaksIT.Dapr is a facade library for Dapr. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.1 | 105 | 3/8/2026 |
| 2.0.0 | 110 | 2/22/2026 |
| 1.1.1 | 213 | 11/3/2025 |
| 1.1.0 | 189 | 11/2/2025 |
| 1.0.9 | 139 | 10/31/2025 |
| 1.0.8 | 134 | 10/31/2025 |
| 1.0.7 | 199 | 10/29/2025 |
| 1.0.6 | 371 | 5/5/2025 |
| 1.0.5 | 300 | 9/28/2024 |
| 1.0.4 | 169 | 9/28/2024 |
| 1.0.3 | 169 | 9/28/2024 |
| 1.0.2 | 159 | 9/28/2024 |
| 1.0.1 | 171 | 9/28/2024 |
| 1.0.0 | 249 | 8/30/2024 |