Ling.RemoteServices.AspNetCore 1.0.0

dotnet add package Ling.RemoteServices.AspNetCore --version 1.0.0
                    
NuGet\Install-Package Ling.RemoteServices.AspNetCore -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.AspNetCore" 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.AspNetCore" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Ling.RemoteServices.AspNetCore" />
                    
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.AspNetCore --version 1.0.0
                    
#r "nuget: Ling.RemoteServices.AspNetCore, 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.AspNetCore@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.AspNetCore&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Ling.RemoteServices.AspNetCore&version=1.0.0
                    
Install as a Cake Tool

Ling.RemoteServices.AspNetCore

Project documentation | 简体中文

Ling.RemoteServices.AspNetCore generates ASP.NET Core Minimal API route groups and handlers for interfaces marked with [RemoteService]. It integrates generated endpoints with dependency injection, native endpoint conventions, Problem Details, file results, and OpenAPI metadata.

Installation

Install the package in the ASP.NET Core host:

dotnet add package Ling.RemoteServices.AspNetCore

The package references Ling.RemoteServices.Abstractions and carries the Minimal API source generator.

Register and map a service

using Ling.RemoteServices.AspNetCore;
using MyApplication.Generated;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRemoteServices();
builder.Services.AddScoped<IWeatherService, WeatherService>();

var app = builder.Build();
app.MapRemoteServices();
app.Run();

Each remote service receives its own generated RouteGroupBuilder. Every declared HTTP method is mapped as an independent endpoint and resolves the contract implementation from dependency injection.

Native AOT

Register a source-generated System.Text.Json context containing every JSON request and response type:

builder.Services.ConfigureHttpJsonOptions(options =>
{
    options.SerializerOptions.TypeInfoResolverChain.Insert(
        0,
        RemoteServiceJsonContext.Default);
});

On JIT hosts, generated endpoints retain ASP.NET Core's native parameter inference and OpenAPI metadata behavior. When dynamic code is unavailable, the same generated mapper selects a reflection-free RequestDelegate that binds path, query, header, JSON body, form, upload, and cancellation values directly. The package assemblies declare trimming and AOT compatibility.

Endpoint policies

Contract policy attributes select host-defined policy names. Configure the corresponding ASP.NET Core services and middleware normally:

builder.Services.AddAuthorization(options =>
    options.AddPolicy("ApiUser", policy => policy.RequireAuthenticatedUser()));

builder.Services.AddCors(options =>
    options.AddPolicy("Frontend", policy =>
        policy.WithOrigins("https://example.com")
            .AllowAnyHeader()
            .AllowAnyMethod()));

builder.Services.AddOutputCache(options =>
    options.AddPolicy("WeatherQueries", policy =>
        policy.Expire(TimeSpan.FromSeconds(30))));

Custom named endpoint policies can combine conventions that do not need a dedicated contract attribute:

builder.Services.AddRemoteServices(options =>
{
    options.AddEndpointPolicy("PublicQuery", context =>
    {
        context.RequireCors("Frontend");
        context.CacheOutput("WeatherQueries");
    });
});

Form and file endpoints retain ASP.NET Core antiforgery metadata. The library does not disable antiforgery automatically.

Fluent conventions

MapRemoteServices() returns a registry implementing IEndpointConventionBuilder:

app.MapRemoteServices(services =>
{
    var weather = services.For<IWeatherService>();

    weather.RequireAuthorization("WeatherReader");
    weather.Operation(nameof(IWeatherService.GetAsync))
        .CacheOutput("WeatherQueries");
});

Use Operation(methodName, RemoteHttpMethod) to target one HTTP operation when a contract method exposes multiple methods.

OpenAPI

Generated endpoints attach native Minimal API metadata such as operation names, summaries, accepted content types, produced responses, and binding sources. Configure the OpenAPI stack supplied by the target ASP.NET Core version:

builder.Services.AddOpenApi();

var app = builder.Build();
app.MapOpenApi();
app.MapRemoteServices();

Error handling

RemoteServiceException is translated to an application/problem+json response. Unknown exceptions are intentionally left to the host's IExceptionHandler, developer exception page, and logging pipeline.

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