Ling.RemoteServices.Client 1.0.0

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

Ling.RemoteServices.Client

Project documentation | 简体中文

Ling.RemoteServices.Client generates type-safe HttpClient proxies for interfaces marked with [RemoteService]. It provides URL formatting, System.Text.Json serialization, streamed downloads, and structured remote-call exceptions without depending on MVC or Microsoft.Extensions.Http.

Installation

Install the package in the Blazor WebAssembly or other client project:

dotnet add package Ling.RemoteServices.Client

The package references Ling.RemoteServices.Abstractions and carries the client proxy source generator.

Register generated clients

Register an HttpClient before calling the generated extension method. The generator places the method in ${RootNamespace}.Generated:

using MyApplication.Generated;

var builder = WebAssemblyHostBuilder.CreateDefault(args);

builder.Services.AddScoped(_ => new HttpClient
{
    BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
});
builder.Services.AddRemoteServiceClients();

Generated proxies are registered as scoped implementations of their contract interfaces. Components and services can inject the interface directly:

@inject IWeatherService WeatherService

@code {
    private WeatherForecast[] forecasts = [];

    protected override async Task OnInitializedAsync()
    {
        forecasts = await WeatherService.GetAsync();
    }
}

Configure serialization

builder.Services.AddRemoteServiceClients(options =>
{
    options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
    options.MaximumErrorBodySize = 64 * 1024;
    options.EnableBrowserRequestStreaming = true;
});

Keep the client JSON options compatible with the server's ASP.NET Core HttpJsonOptions, especially when using custom converters or polymorphism.

Native AOT JSON metadata

Native AOT applications must use System.Text.Json source generation. Put the serializer context in the shared contract assembly and register it with the client:

[JsonSerializable(typeof(WeatherForecast[]))]
public sealed partial class RemoteServiceJsonContext : JsonSerializerContext
{
}

builder.Services.AddRemoteServiceClients(options =>
    options.AddJsonSerializerContext(RemoteServiceJsonContext.Default));

Generated proxies pass strongly typed JsonTypeInfo<T> instances to JsonContent and response deserialization. Protocol-owned Problem Details metadata is included by the client package itself.

Select another HTTP method

When a contract method declares multiple HTTP operations, the normal interface call uses the operation marked IsClientDefault = true. Select another generated operation through an immutable proxy view:

var items = await service
    .WithHttpMethod(RemoteHttpMethod.Post)
    .GetItemsAsync(query, cancellationToken);

Local implementations are returned unchanged, which allows the same component code to run with a local implementation during Interactive Server rendering and a generated proxy after switching to WebAssembly.

Errors and streamed files

  • Non-success responses produce RemoteCallException with status, Problem Details, headers, operation name, and a bounded response summary.
  • Network, protocol, and deserialization failures produce RemoteTransportException.
  • Caller cancellation remains OperationCanceledException.
  • RemoteFile owns the HTTP response lifetime for streamed downloads and must be disposed or asynchronously disposed by the caller.

HttpClient pipeline

Authentication, cookies, bearer tokens, retry, logging, and tracing should be configured on the HttpClient supplied by the host. Generated proxies reuse that instance rather than creating a separate networking stack.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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
1.0.0 102 8/31/2026