Soenneker.Blazor.Consumers.Base
11.0.1268
Prefix Reserved
dotnet add package Soenneker.Blazor.Consumers.Base --version 11.0.1268
NuGet\Install-Package Soenneker.Blazor.Consumers.Base -Version 11.0.1268
<PackageReference Include="Soenneker.Blazor.Consumers.Base" Version="11.0.1268" />
<PackageVersion Include="Soenneker.Blazor.Consumers.Base" Version="11.0.1268" />
<PackageReference Include="Soenneker.Blazor.Consumers.Base" />
paket add Soenneker.Blazor.Consumers.Base --version 11.0.1268
#r "nuget: Soenneker.Blazor.Consumers.Base, 11.0.1268"
#:package Soenneker.Blazor.Consumers.Base@11.0.1268
#addin nuget:?package=Soenneker.Blazor.Consumers.Base&version=11.0.1268
#tool nuget:?package=Soenneker.Blazor.Consumers.Base&version=11.0.1268
Soenneker.Blazor.Consumers.Base
A base class that sends common API requests through IApiClient and converts JSON success or problem-details responses into OperationResult<T>.
Use this package when one consumer needs different response types per operation. If every operation uses the same response type, Soenneker.Blazor.Consumer provides the typed Consumer<TResponse> layer.
Installation
dotnet add package Soenneker.Blazor.Consumers.Base
Define and register a consumer
BaseConsumer has a protected constructor, so derive an application-specific class and choose its URI prefix:
using Microsoft.Extensions.Logging;
using Soenneker.Blazor.ApiClient.Abstract;
using Soenneker.Blazor.Consumers.Base;
public sealed class CatalogConsumer : BaseConsumer
{
public CatalogConsumer(
IApiClient apiClient,
ILogger<BaseConsumer> logger,
IConfiguration configuration)
: base(apiClient, logger, "catalog/products")
{
apiClient.Initialize(
configuration["Api:BaseUrl"]!,
requestResponseLogging: false);
}
}
using Soenneker.Blazor.ApiClient.Registrars;
builder.Services.AddApiClientAsScoped();
builder.Services.AddScoped<CatalogConsumer>();
Send requests
The response type is selected on each call:
OperationResult<ProductDto> product = await catalog.Get<ProductDto>(
"42",
cancellationToken: cancellationToken);
OperationResult<PagedResult<ProductSummaryDto>> page =
await catalog.GetAll<ProductSummaryDto>(
requestDataOptions,
cancellationToken: cancellationToken);
OperationResult<ProductDto> created = await catalog.Create<ProductDto>(
new CreateProductRequest(name, price),
cancellationToken: cancellationToken);
Without overrideUri, single-resource GET, PUT, DELETE, and upload calls append the supplied ID directly to the configured prefix. Collection GET and POST use the prefix itself. An upload appends /{id}/upload. overrideUri replaces that entire generated relative URI.
Use a RequestOptions overload when you already have the exact URI, payload, anonymity choice, and logging flags:
OperationResult<ProductDto> result = await catalog.Post<ProductDto>(
new RequestOptions
{
Uri = "catalog/products/import",
Object = request,
AllowAnonymous = false,
LogResponse = true
},
cancellationToken);
Results and failures
Successful JSON is deserialized into result.Value; a problem-details response is exposed through result.Problem, with Succeeded, Failed, and StatusCode available for branching. Empty successful responses produce a successful result with a null value. Invalid or unexpected response JSON produces a failed result; transport, authentication, and cancellation failures may throw.
The consumer owns and disposes the underlying HttpResponseMessage after conversion.
Uploads are always authenticated. Passing allowAnonymous: true or setting RequestUploadOptions.AllowAnonymous throws NotSupportedException. Upload content uses file and optional json multipart fields, and the supplied stream is disposed after the request.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.Blazor.Consumers.Core (>= 11.0.833)
- Soenneker.Dtos.RequestDataOptions (>= 11.0.256)
- Soenneker.Dtos.Results.Paged (>= 11.0.73)
- Soenneker.Extensions.HttpResponseMessage (>= 11.0.2678)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Blazor.Consumers.Base:
| Package | Downloads |
|---|---|
|
Soenneker.Blazor.Consumer
A derivative of Soenneker.Blazor.Consumer.Base, providing instance-wide generic type setting. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.1268 | 181 | 11/19/2026 |
| 11.0.1267 | 116 | 11/19/2026 |
| 11.0.1266 | 121 | 11/19/2026 |
| 11.0.1265 | 116 | 11/19/2026 |
| 11.0.1262 | 133 | 11/18/2026 |
| 11.0.1261 | 103 | 11/18/2026 |
| 11.0.1260 | 112 | 11/18/2026 |
| 11.0.1259 | 97 | 11/18/2026 |
| 11.0.1258 | 125 | 11/18/2026 |
| 11.0.1257 | 113 | 11/17/2026 |
| 11.0.1256 | 113 | 11/16/2026 |
| 11.0.1255 | 122 | 11/16/2026 |
| 11.0.1254 | 112 | 11/16/2026 |
| 11.0.1253 | 100 | 11/15/2026 |
| 11.0.1252 | 108 | 11/15/2026 |
| 11.0.1251 | 109 | 11/15/2026 |
| 11.0.1250 | 113 | 11/15/2026 |
| 11.0.1249 | 113 | 11/15/2026 |
| 11.0.1248 | 117 | 11/14/2026 |
| 11.0.1246 | 110 | 11/14/2026 |
Updated Soenneker.Blazor.Consumers.Core to 11.0.833