Ybd.AbpLite.UnifiedResponse 2.0.0

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

Ybd.AbpLite.UnifiedResponse

ABP 统一返回模块。默认把 /api/app 下的成功结果、业务异常、参数校验、401/403 包装成:

{ "success": true, "data": { }, "error": null }
{
  "success": false,
  "data": null,
  "error": {
    "code": "MyProject:Order:0001",
    "message": "订单不存在",
    "details": null,
    "data": null,
    "validationErrors": []
  }
}

错误信息直接使用 ABP 的 RemoteServiceErrorInfo,因此保留 ABP 的错误码、本地化和校验结构。

引入

[DependsOn(typeof(AbpLiteUnifiedResponseModule))]
public class MyHostModule : AbpModule
{
}

配置节 UnifiedResponse:

{
  "UnifiedResponse": {
    "Enabled": true,
    "Mode": "Envelope",
    "AllowNativeOverride": true,
    "IncludePaths": [ "/api/app" ],
    "ExcludePaths": [ "/swagger", "/api/abp" ],
    "AlwaysReturnHttp200": false,
    "ErrorCodePrefix": "MyProject"
  }
}

原生格式

前端默认拿信封。ABP 动态客户端共享 Application.Contracts 时,不希望成功响应被包一层,可以:

X-Unified-Response: native

服务端会返回裸 DTO 和 ABP 原生错误。Ybd.AbpLite.UnifiedResponse.Client 包会自动给 ABP 动态代理加这个请求头。

自定义

  • 换信封结构:实现 IUnifiedResponseBuilder 并替换默认实现;
  • 换异常/状态码映射:实现 IUnifiedResponseErrorMapper;
  • 换包装范围:实现 IUnifiedResponsePolicy;
  • 换响应写入:实现 IUnifiedResponseWriter;
  • 单个接口退出:标 [SkipUnifiedResponse]。

所有默认实现都通过 ABP 依赖注入注册,使用 [Dependency(ReplaceServices = true)] 即可替换。

Product Compatible and additional computed target framework versions.
.NET 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
2.0.0 94 10/29/2026
1.0.0 94 10/26/2026