JV.ResultUtilities.AspNetCore
11.0.0
dotnet add package JV.ResultUtilities.AspNetCore --version 11.0.0
NuGet\Install-Package JV.ResultUtilities.AspNetCore -Version 11.0.0
<PackageReference Include="JV.ResultUtilities.AspNetCore" Version="11.0.0" />
<PackageVersion Include="JV.ResultUtilities.AspNetCore" Version="11.0.0" />
<PackageReference Include="JV.ResultUtilities.AspNetCore" />
paket add JV.ResultUtilities.AspNetCore --version 11.0.0
#r "nuget: JV.ResultUtilities.AspNetCore, 11.0.0"
#:package JV.ResultUtilities.AspNetCore@11.0.0
#addin nuget:?package=JV.ResultUtilities.AspNetCore&version=11.0.0
#tool nuget:?package=JV.ResultUtilities.AspNetCore&version=11.0.0
JV.ResultUtilities.AspNetCore
The ASP.NET Core bridge for JV.ResultUtilities: one
exception handler that turns a thrown ResultException into an RFC 9457 problem body, with the HTTP
status coming from the failing key, structured errors / validation extensions for clients, and
request validation through AbstractValidator<T>.
// Program.cs
builder.Services.AddControllers();
builder.Services.AddResultProblemDetails<ResxResultMessageTranslator>(options =>
{
options.MapStatus(ValidationKeys.Legacy.Locked, 423); // for keys you do not own
});
builder.Services.AddResultValidation(typeof(Program).Assembly);
var app = builder.Build();
app.UseExceptionHandler();
app.MapControllers();
// Domain: the key says what it is over HTTP
public static readonly ValidationKeyDefinition NotFound =
ValidationKeyDefinition.Create("User.NotFound").WithGuidParameter("id")
.WithHttpStatusCode(HttpStatusCode.NotFound); // core helper; WithHttpStatus(404) is the int form
// Controller: no HasError ladder
var (result, user) = await service.GetAsync(id, ct);
result.ThrowIfFailure(); // → 404 application/problem+json
return Ok(UserResponse.Map(user));
The body:
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.5",
"title": "Not Found",
"status": 404,
"detail": "User 3f2c… was not found.",
"instance": "GET /api/users/3f2c…",
"traceId": "…", "requestId": "…",
"errors": { "": ["User 3f2c… was not found."] },
"validation": [{ "key": "User.NotFound", "field": null, "message": "…", "parameters": { "id": "3f2c…" } }]
}
errorsuses ASP.NET Core's ownValidationProblemDetailsshape (field → messages), so a client's existing model-binding error path handles domain failures too.validationis lossless: stable key to branch on, field, translated message, named raw parameters.- The handler answers only
ResultException. Anything else returnsfalseand the framework's default handling logs it and writes a 500 with no exception message — so this package never leaks one. - Status per message:
WithHttpStatusCode(or the intWithHttpStatus) on the key, elseoptions.MapStatus, elseDefaultStatusCode(400). Several messages: all equal → that status; otherwise any 5xx → the highest, else the default. - Validation failures are logged at
Information(configurable). They are client errors.
IResultMessageTranslator is the one seam you implement: string Translate(ValidationMessage). The
fallback returns the key. ValidateModelFilter runs every registered IValidator against matching
action arguments before the action and throws the same ResultException, so request-shape and
business-rule failures share one wire shape.
| 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
- JV.ResultUtilities (>= 11.0.0)
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 |
|---|---|---|
| 11.0.0 | 93 | 9/20/2026 |