Viaduct.Client
0.1.1
dotnet add package Viaduct.Client --version 0.1.1
NuGet\Install-Package Viaduct.Client -Version 0.1.1
<PackageReference Include="Viaduct.Client" Version="0.1.1" />
<PackageVersion Include="Viaduct.Client" Version="0.1.1" />
<PackageReference Include="Viaduct.Client" />
paket add Viaduct.Client --version 0.1.1
#r "nuget: Viaduct.Client, 0.1.1"
#:package Viaduct.Client@0.1.1
#addin nuget:?package=Viaduct.Client&version=0.1.1
#tool nuget:?package=Viaduct.Client&version=0.1.1
Viaduct.Client
Define your service interface once. Viaduct wires it to an ASP.NET Core server and a typed HTTP client — automatically, at compile time, with no duplication.
Viaduct.Client is the client-side package. It reads your interface at compile time and generates a typed HttpClient proxy — you inject the interface and call methods as if they were local. The server project uses the same interface to generate matching endpoints, so both sides stay in sync automatically.
The single-source-of-truth model
┌─────────────────────────────────────────┐
│ Shared project (IUserService) │
│ Define once. Change once. Done. │
└────────────┬────────────────────────────┘
│
▼
┌──────────────────────┐
│ Your client project │ ← references Viaduct.Client
│ (this package) │
│ │
│ CreateAndAddHttpClient│ → GET https://api/.../GetUserAsync/{id}
│ <IUserService>() │ POST https://api/.../CreateUserAsync/...
└──────────────────────┘
Quick start
// Program.cs (client app)
builder.Services.CreateAndAddHttpClient<IUserService>(options =>
{
options.BaseUrl = "https://api.example.com";
});
// Inject and use anywhere — looks like a local call
public class Dashboard(IUserService users)
{
public async Task<User> Load(int id) => await users.GetUserAsync(id);
}
Configuration
builder.Services.CreateAndAddHttpClient<IUserService>(options =>
{
options.BaseUrl = "https://api.example.com";
options.BasePath = "/api/v1";
options.UseInterfaceNameForPath = true;
})
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler());
Parameter binding
- Simple types (
int,string,bool,DateTime,Guid, etc.) → route or query parameters - Complex types (classes, records) → JSON request body
CancellationToken→ forwarded to the HTTP call, never serialized
Error handling
Any non-2xx response throws a ViaductException wrapping the underlying HttpRequestException.
Which package do I need?
| Your project | Package |
|---|---|
| Defines the shared interface | Viaduct.Core |
| ASP.NET Core server | Viaduct.Server |
| Client / consumer app | Viaduct.Client |
| Needs both (integration tests, monolith) | Viaduct |
Requirements
- .NET 8, 9, or 10
- C# 14+ (uses
[InterceptsLocation]for compile-time interception)
| 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
- Microsoft.Extensions.Http (>= 8.0.0)
- Subro.Json (>= 0.0.1)
- Viaduct.Core (>= 0.1.1)
-
net8.0
- Microsoft.Extensions.Http (>= 8.0.0)
- Subro.Json (>= 0.0.1)
- Viaduct.Core (>= 0.1.1)
-
net9.0
- Microsoft.Extensions.Http (>= 8.0.0)
- Subro.Json (>= 0.0.1)
- Viaduct.Core (>= 0.1.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Viaduct.Client:
| Package | Downloads |
|---|---|
|
Viaduct
Meta-package that includes both Viaduct.Server and Viaduct.Client. Reference this package when your project needs both server-side endpoint mapping and client-side HTTP proxy generation (e.g. integration tests, monoliths). For most projects, reference Viaduct.Server or Viaduct.Client directly instead. |
GitHub repositories
This package is not used by any popular GitHub repositories.