Despro.Framework.WebClient 2.0.7

dotnet add package Despro.Framework.WebClient --version 2.0.7
                    
NuGet\Install-Package Despro.Framework.WebClient -Version 2.0.7
                    
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="Despro.Framework.WebClient" Version="2.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Despro.Framework.WebClient" Version="2.0.7" />
                    
Directory.Packages.props
<PackageReference Include="Despro.Framework.WebClient" />
                    
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 Despro.Framework.WebClient --version 2.0.7
                    
#r "nuget: Despro.Framework.WebClient, 2.0.7"
                    
#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 Despro.Framework.WebClient@2.0.7
                    
#: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=Despro.Framework.WebClient&version=2.0.7
                    
Install as a Cake Addin
#tool nuget:?package=Despro.Framework.WebClient&version=2.0.7
                    
Install as a Cake Tool

Despro.Framework.WebClient

The typed HTTP client layer of Despro Framework.

Despro.Framework.WebClient provides a typed outbound HTTP client (IHttp / Http) for service-to-service integration. It serializes with Newtonsoft.Json, forwards the current user's bearer token (via IAuthService), unwraps the framework's ApiResultHttp envelope, and is registered over a named HttpClient.

  • Package: Despro.Framework.WebClient
  • Version: 2.0.4
  • Target framework: net10.0
  • Depends on: Despro.Framework.Base

Installation

dotnet add package Despro.Framework.WebClient

DI registration

using Despro.Framework.WebClient;

builder.Services.AddFrameworkWebClient();

AddFrameworkWebClient registers IHttp → Http (scoped) and configures a named HttpClient (Constants.HttpClientName) with an application/json Accept header and a 5-minute timeout.

Note: the configured primary handler disables server-certificate validation (ServerCertificateCustomValidationCallback => true), which is intended for trusted internal integrations. Review this before using it against untrusted endpoints.


IHttp

A typed client covering the common HTTP verbs plus form and file operations. Every method accepts apiResult (unwrap the ApiResultHttp envelope), isAuth (attach the bearer token), an explicit token, and isRole flags.

Method Purpose
GetAsync<TOut> GET and deserialize TOut.
PostAsync<TIn, TOut> / PutAsync / PatchAsync JSON body request/response.
PostFormAsync<TIn, TOut> / PutFormAsync / PatchFormAsync multipart/form-data from a model's properties.
DeleteAsync<TOut> DELETE and deserialize TOut.
GetFileAsync Download a response as a MemoryStream.
UploadFile<TOut> Upload an IFormFile.

On non-success responses the client throws WebClientException.


Usage

public class CatalogClient(IHttp http)
{
    public Task<ProductDto> GetProductAsync(long id)
        => http.GetAsync<ProductDto>($"https://catalog.internal/api/v1/products/{id}");

    public Task<long> CreateProductAsync(CreateProductRequest request)
        => http.PostAsync<CreateProductRequest, long>("https://catalog.internal/api/v1/products", request);
}

By default (isAuth: true) the current request's bearer token is forwarded to the downstream service; pass an explicit token to override it.


Exceptions

  • WebClientBaseException (abstract, extends Base's BaseException).
  • WebClientException — thrown on HTTP failures / non-success responses.

Project structure

Despro.Framework.WebClient
├── IRepository/            # IHttp contract
├── Repository/             # Http implementation
├── WebClientExceptions/    # WebClientBaseException, WebClientException
└── FrameworkWebClientDi.cs # AddFrameworkWebClient
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
2.0.7 125 7/26/2026
2.0.6 119 7/18/2026
2.0.5 120 7/2/2026
2.0.4 120 7/2/2026