Soenneker.Blazor.Consumers.Base
11.0.1250
Prefix Reserved
dotnet add package Soenneker.Blazor.Consumers.Base --version 11.0.1250
NuGet\Install-Package Soenneker.Blazor.Consumers.Base -Version 11.0.1250
<PackageReference Include="Soenneker.Blazor.Consumers.Base" Version="11.0.1250" />
<PackageVersion Include="Soenneker.Blazor.Consumers.Base" Version="11.0.1250" />
<PackageReference Include="Soenneker.Blazor.Consumers.Base" />
paket add Soenneker.Blazor.Consumers.Base --version 11.0.1250
#r "nuget: Soenneker.Blazor.Consumers.Base, 11.0.1250"
#:package Soenneker.Blazor.Consumers.Base@11.0.1250
#addin nuget:?package=Soenneker.Blazor.Consumers.Base&version=11.0.1250
#tool nuget:?package=Soenneker.Blazor.Consumers.Base&version=11.0.1250
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.818)
- Soenneker.Dtos.RequestDataOptions (>= 11.0.253)
- Soenneker.Dtos.Results.Paged (>= 11.0.71)
- Soenneker.Extensions.HttpResponseMessage (>= 11.0.2665)
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.1250 | 0 | 11/15/2026 |
| 11.0.1249 | 0 | 11/15/2026 |
| 11.0.1248 | 0 | 11/14/2026 |
| 11.0.1246 | 43 | 11/14/2026 |
| 11.0.1245 | 118 | 11/12/2026 |
| 11.0.1244 | 83 | 11/12/2026 |
| 11.0.1243 | 83 | 11/12/2026 |
| 11.0.1242 | 84 | 11/11/2026 |
| 11.0.1241 | 77 | 11/11/2026 |
| 11.0.1239 | 99 | 11/11/2026 |
| 11.0.1238 | 85 | 11/11/2026 |
| 11.0.1237 | 92 | 11/11/2026 |
| 11.0.1235 | 96 | 11/11/2026 |
| 11.0.1234 | 84 | 11/11/2026 |
| 11.0.1233 | 91 | 11/11/2026 |
| 11.0.1232 | 95 | 11/11/2026 |
| 11.0.1230 | 82 | 11/11/2026 |
| 11.0.1228 | 91 | 11/11/2026 |
| 11.0.1226 | 87 | 11/11/2026 |
| 11.0.1224 | 94 | 11/11/2026 |
Update dependency Soenneker.Blazor.Consumers.Core to 11.0.818 (#1781)