Soenneker.Blazor.Consumer 4.0.1937

Prefix Reserved
dotnet add package Soenneker.Blazor.Consumer --version 4.0.1937
                    
NuGet\Install-Package Soenneker.Blazor.Consumer -Version 4.0.1937
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Blazor.Consumer" Version="4.0.1937" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Blazor.Consumer" Version="4.0.1937" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Blazor.Consumer" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Blazor.Consumer --version 4.0.1937
                    
#r "nuget: Soenneker.Blazor.Consumer, 4.0.1937"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Blazor.Consumer@4.0.1937
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Blazor.Consumer&version=4.0.1937
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Blazor.Consumer&version=4.0.1937
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1937 60 10/4/2026
4.0.1936 55 10/3/2026
4.0.1935 41 10/3/2026
4.0.1934 141 9/30/2026
4.0.1933 74 9/30/2026
4.0.1932 79 9/30/2026
4.0.1931 78 9/30/2026
4.0.1930 77 9/30/2026
4.0.1929 80 9/30/2026
4.0.1927 83 9/30/2026
4.0.1926 77 9/29/2026
4.0.1925 80 9/29/2026
4.0.1924 85 9/29/2026
4.0.1923 80 9/28/2026
4.0.1922 86 9/26/2026
4.0.1921 88 9/26/2026
4.0.1918 96 9/25/2026
4.0.1917 95 9/24/2026
4.0.1915 89 9/24/2026
4.0.1914 86 9/24/2026
Loading failed

Update dependency Soenneker.Blazor.Consumers.Base to 4.0.1143 (#2469)