Soenneker.Blazor.Consumer
4.0.1850
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Blazor.Consumer --version 4.0.1850
NuGet\Install-Package Soenneker.Blazor.Consumer -Version 4.0.1850
<PackageReference Include="Soenneker.Blazor.Consumer" Version="4.0.1850" />
<PackageVersion Include="Soenneker.Blazor.Consumer" Version="4.0.1850" />
<PackageReference Include="Soenneker.Blazor.Consumer" />
paket add Soenneker.Blazor.Consumer --version 4.0.1850
#r "nuget: Soenneker.Blazor.Consumer, 4.0.1850"
#:package Soenneker.Blazor.Consumer@4.0.1850
#addin nuget:?package=Soenneker.Blazor.Consumer&version=4.0.1850
#tool nuget:?package=Soenneker.Blazor.Consumer&version=4.0.1850
Soenneker.Blazor.Consumer
A typed base class for app-specific Blazor API consumers that return OperationResult<TResponse> from common CRUD and upload requests.
Installation
dotnet add package Soenneker.Blazor.Consumer
Define a consumer
Consumer<TResponse> has a protected constructor. Derive a concrete consumer and choose the resource URI prefix once:
using Microsoft.Extensions.Logging;
using Soenneker.Blazor.ApiClient.Abstract;
using Soenneker.Blazor.Consumer;
public sealed class TodoConsumer : Consumer<TodoDto>
{
public TodoConsumer(
IApiClient apiClient,
ILogger<Consumer<TodoDto>> logger,
IConfiguration configuration)
: base(apiClient, logger, "todos")
{
apiClient.Initialize(
configuration["Api:BaseUrl"]!,
requestResponseLogging: false);
}
}
Register the API client and concrete consumer as scoped services:
using Soenneker.Blazor.ApiClient.Registrars;
builder.Services.AddApiClientAsScoped();
builder.Services.AddScoped<TodoConsumer>();
Use it
OperationResult<TodoDto> result = await todoConsumer.Get(
id: "42",
cancellationToken: cancellationToken);
if (result.Succeeded)
{
TodoDto? todo = result.Value;
}
else
{
ProblemDetailsDto? problem = result.Problem;
}
The generic response type is fixed for Get, Create, Post, Update, Put, and Delete. GetAll returns OperationResult<PagedResult<TodoDto>>; Upload returns OperationResult<FileUploadResponse>.
Default routes
For a prefix of todos, the convenience overloads build these relative URIs:
| Call | URI |
|---|---|
Get("42"), Update("42", request), Put("42", request), Delete("42") |
todos/42 |
GetAll(), Create(request), Post(request) |
todos |
Upload("42", stream, "file.pdf") |
todos/42/upload |
overrideUri replaces the entire default URI. Use the RequestOptions overloads when the endpoint does not follow these conventions or when per-request anonymity and logging flags are needed. allowAnonymous defaults to false for JSON requests.
Responses are deserialized into the success value for successful status codes or into problem details for error responses. A response body that does not match the expected JSON shape produces a failed OperationResult; transport, authentication, and cancellation failures may still throw.
Uploads use multipart fields named file and json. The underlying API client disposes the supplied upload stream after the request, so do not reuse it.
| 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
- Soenneker.Blazor.Consumers.Base (>= 4.0.1014)
- Soenneker.Responses.FileUpload (>= 4.0.395)
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 |
|---|---|---|
| 4.0.1855 | 75 | 9/1/2026 |
| 4.0.1854 | 62 | 9/1/2026 |
| 4.0.1853 | 76 | 9/1/2026 |
| 4.0.1852 | 66 | 9/1/2026 |
| 4.0.1851 | 68 | 9/1/2026 |
| 4.0.1850 | 80 | 8/31/2026 |
| 4.0.1849 | 80 | 8/31/2026 |
| 4.0.1848 | 67 | 8/31/2026 |
| 4.0.1846 | 79 | 8/31/2026 |
| 4.0.1845 | 82 | 8/31/2026 |
| 4.0.1844 | 79 | 8/31/2026 |
| 4.0.1843 | 75 | 8/30/2026 |
| 4.0.1842 | 82 | 8/30/2026 |
| 4.0.1841 | 85 | 8/30/2026 |
| 4.0.1840 | 92 | 8/30/2026 |
| 4.0.1839 | 79 | 8/30/2026 |
| 4.0.1838 | 69 | 8/30/2026 |
| 4.0.1837 | 79 | 8/29/2026 |
| 4.0.1836 | 75 | 8/29/2026 |
| 4.0.1834 | 87 | 8/29/2026 |
Update dependency Soenneker.Blazor.Consumers.Base to 4.0.1014 (#2370)