LiteOrm.Remote.Server 8.1.9

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

LiteOrm.Remote.Server

License GitHub


📖 English Version

LiteOrm.Remote.Server is the server-side package of LiteOrm's remote service invocation. It receives HTTP calls dispatched by LiteOrm.Remote clients, resolves the target service from the DI container, executes the method, and returns the result (including identity write-back values).

When to Use

  • You want to host a centralized data-access layer that multiple frontend apps can call.
  • You need to keep database access and connection strings entirely server-side.
  • You want to expose LiteOrm-based IEntityService<T> / custom [Service] interfaces over HTTP without writing controllers manually.

Requirements

  • .NET 8.0+ (server-side only; ASP.NET Core based)
  • Dependencies: LiteOrm.Common, Microsoft.AspNetCore.App
  • Clients must use LiteOrm.Remote to ensure protocol compatibility

Installation

dotnet add package LiteOrm.Remote.Server

Quick Start

using LiteOrm.Remote.Server;

var builder = WebApplication.CreateBuilder(args);
builder.Host.RegisterLiteOrm();        // Register the LiteOrm core framework
builder.Services.AddRemoteServer();    // Register the remote server

var app = builder.Build();
app.MapRemoteInvokeEndpoint();         // Map the remote invocation endpoint
app.Run();

For authenticated access, implement IRemoteAuthenticationHandler and register it in DI. If using ASP.NET Core Identity, use the built-in IdentityRemoteAuthenticationHandler<TUser>:

// Using ASP.NET Core Identity
builder.Services.AddIdentity<MyUser, MyRole>().AddEntityFrameworkStores<MyDbContext>();
builder.Services.AddSingleton<IRemoteAuthenticationHandler, IdentityRemoteAuthenticationHandler<MyUser>>();
builder.Services.AddRemoteServer();

// Or implement IRemoteAuthenticationHandler directly for custom auth (JWT, etc.)
builder.Services.AddSingleton<IRemoteAuthenticationHandler, MyAuthHandler>();
builder.Services.AddRemoteServer();

That's it — interfaces marked with [Service] and registered in DI are now remotely callable.

Request authentication is handled by your IRemoteAuthenticationHandler; RemoteServerOptions.EnableAuthentication (default false) is only an opt-in that wires up ASP.NET Core cookie authentication scaffolding, and is not required for the Identity handler above.

How It Works

  1. Client sends a RemoteInvocationRequest (service name + method + arguments) via HTTP.
  2. Server resolves ServiceName to a concrete type via TypeResolverHelper, gets the instance from DI.
  3. Server invokes the method, collects ArgumentOut write-back values, and returns a RemoteInvocationResponse.
  4. Client proxy writes back identity / out parameters and completes the task.

Highlights

  • Zero-Controller Exposure: no need to write controllers per service; one endpoint dispatches all [Service] interfaces.
  • Ticket-based Authentication: implement IRemoteAuthenticationHandler or use the built-in IdentityRemoteAuthenticationHandler<TUser> (obtains SignInManager<TUser> from DI). The SignIn/SignOut endpoints are mapped automatically.
  • Identity Write-back: ArgumentOutAttribute + IdentityArgumentOutHandler return auto-generated identity values to the client automatically.
  • DI-Integrated: services are resolved from the ASP.NET Core DI container, so scoped services and transactions work as expected.
  • Shared Protocol: DTOs live in LiteOrm.Common, keeping client/server wire format in sync.

📖 中文版本

LiteOrm.Remote.Server 是 LiteOrm 远程服务调用的服务端包。它接收由 LiteOrm.Remote 客户端通过 HTTP 发起的调用,从 DI 容器解析目标服务实例、执行方法并返回结果(包含标识值回写)。

适用场景

  • 希望集中部署数据访问层,供多个前端应用调用。
  • 需要把数据库访问与连接串完全保留在服务端。
  • 希望在不手写 Controller 的情况下,通过 HTTP 暴露基于 LiteOrm 的 IEntityService<T> 或自定义 [Service] 接口。

环境要求

  • .NET 8.0+(仅服务端,基于 ASP.NET Core)
  • 依赖库:LiteOrm.Common、Microsoft.AspNetCore.App
  • 客户端必须使用 LiteOrm.Remote 以保证协议一致

安装

dotnet add package LiteOrm.Remote.Server

快速入门

using LiteOrm.Remote.Server;

var builder = WebApplication.CreateBuilder(args);
builder.Host.RegisterLiteOrm();        // 注册 LiteOrm 主框架
builder.Services.AddRemoteServer();    // 注册远程服务端

var app = builder.Build();
app.MapRemoteInvokeEndpoint();         // 映射远程调用端点
app.Run();

如需身份认证,实现 IRemoteAuthenticationHandler 并注册到 DI。若使用 ASP.NET Core Identity,可直接使用内置的 IdentityRemoteAuthenticationHandler<TUser>:

// 使用 ASP.NET Core Identity
builder.Services.AddIdentity<MyUser, MyRole>().AddEntityFrameworkStores<MyDbContext>();
builder.Services.AddSingleton<IRemoteAuthenticationHandler, IdentityRemoteAuthenticationHandler<MyUser>>();
builder.Services.AddRemoteServer();

// 或直接实现 IRemoteAuthenticationHandler 进行自定义认证(JWT 等)
builder.Services.AddSingleton<IRemoteAuthenticationHandler, MyAuthHandler>();
builder.Services.AddRemoteServer();

完成 — 标记了 [Service] 特性并注册到 DI 的接口现在即可被远程调用。

请求认证由你注册的 IRemoteAuthenticationHandler 完成;RemoteServerOptions.EnableAuthentication(默认为 false)只是可选的入门开关,用于装配 ASP.NET Core Cookie 认证脚手架,上面的 Identity 示例无需设置它。

工作原理

  1. 客户端通过 HTTP 发送 RemoteInvocationRequest(服务名 + 方法 + 参数)。
  2. 服务端通过 TypeResolverHelper 将 ServiceName 解析为具体类型,从 DI 获取实例。
  3. 服务端执行方法,收集 ArgumentOut 回写值,返回 RemoteInvocationResponse。
  4. 客户端代理回写标识值 / out 参数,完成任务。

主要特性

  • 零 Controller 暴露:无需为每个服务编写 Controller;单个端点分发所有 [Service] 接口。
  • 票据身份认证:实现 IRemoteAuthenticationHandler 或使用内置 IdentityRemoteAuthenticationHandler<TUser>(从 DI 获取 SignInManager<TUser>)。SignIn/SignOut 端点自动映射。
  • 标识值自动回写:ArgumentOutAttribute + IdentityArgumentOutHandler 自动把生成的标识值返回给客户端。
  • DI 集成:服务从 ASP.NET Core DI 容器解析,作用域服务与事务行为符合预期。
  • 共享协议:DTO 位于 LiteOrm.Common,客户端 / 服务端传输格式天然一致。

📚 相关资源 / Resources

📄 License

MIT License

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 was computed.  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
8.1.9 92 9/22/2026
8.1.6 91 9/10/2026
8.1.5 99 9/5/2026
8.0.4 117 8/6/2026
8.0.3 119 7/28/2026
8.0.2 114 7/6/2026
8.0.1 119 6/30/2026

8.1.9:
- 同步 LiteOrm.Common 8.1.9 / LiteOrm 8.1.9。