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
<PackageReference Include="Ling.RemoteServices.Client" Version="1.0.0" />
<PackageVersion Include="Ling.RemoteServices.Client" Version="1.0.0" />
<PackageReference Include="Ling.RemoteServices.Client" />
paket add Ling.RemoteServices.Client --version 1.0.0
#r "nuget: Ling.RemoteServices.Client, 1.0.0"
#:package Ling.RemoteServices.Client@1.0.0
#addin nuget:?package=Ling.RemoteServices.Client&version=1.0.0
#tool nuget:?package=Ling.RemoteServices.Client&version=1.0.0
Ling.RemoteServices.Client
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
RemoteCallExceptionwith status, Problem Details, headers, operation name, and a bounded response summary. - Network, protocol, and deserialization failures produce
RemoteTransportException. - Caller cancellation remains
OperationCanceledException. RemoteFileowns 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
| Product | Versions 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. |
-
net10.0
- Ling.RemoteServices.Abstractions (>= 1.0.0)
-
net8.0
- Ling.RemoteServices.Abstractions (>= 1.0.0)
-
net9.0
- Ling.RemoteServices.Abstractions (>= 1.0.0)
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 |