Yyt.Abp.ApiController 1.0.6

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

Yyt.Abp.ApiController


English Version

Overview

Yyt.Abp.ApiController is a lightweight library designed to streamline API routing, standardize input/output parameter formatting, and simplify static image configuration, and provide global standardized exception handling in .NET applications,Version 1.0.3 Remove AddMvc configuration and switch to AddControllers, Version 1.0.6 added support for net8 and net10. Built with a modular architecture, it integrates seamlessly into your existing projects. Supported by Patrick.Z, this library alleviates the burden of repetitive daily development configurations, allowing you to focus on core business logic.

Why Choose Yyt.Abp.ApiController?

  • Minimal Dependencies: Lightweight design with few external dependencies, ensuring high performance and easy integration.
  • Secure by Design: Built with security best practices in mind to protect your application endpoints.
  • Highly Extensible: Flexible architecture allows for easy customization to meet advanced use cases.
  • Battle-Tested: Proven reliability through validation in multiple production projects.

Key Features

1. Simplified Static Image Configuration

Automatically maps image paths from wwwroot\images, with separate configurations for Mobile and Web clients.The wwwroot/image directory folder must exist in the project root directory.

Access Example: http://file/{imageUrl}

2. Flexible API Route Prefix Rewriting

Supports custom rewriting of primary and secondary API route prefixes. For instance, if the primary prefix is configured as yyt. The ExcludeFromRouteRewrite attribute prevents the execution of primary and secondary route rewriting rules.

Access Example: http://xxx/yyt/api/login

3. Automatic Parameter Formatting

Standardizes API communication formats out of the box:

  • Naming Convention: Automatically converts all API input and output parameters to camelCase.
  • Date Formatting: Normalizes date-time objects to the standard yyyy-MM-dd HH:mm:ss format.

‌#### 4.Global Custom Exception Handling and Standardized Information Output

‌Standardized Error Response Example


{
	"data": "error msg ...",
	"code": 0,
	"msg": "",
	"success": true,
	"timestamp": 1782177092999
}

Code Integration Example

namespace Demo.HttpApi.Host
{
    [DependsOn(
      typeof(VoloApiControllerModule)
    )]
    public class DemoHttpApiHostModule : AbpModule
    {
        // config service & other
    }
}

ExcludeFromRouteRewrite Attribute Code Example:

[HttpPost]
[Route("add")]
[ExcludeFromRouteRewrit]
public async Task<ServiceResult<string>> AddData(AddDataInput input)
{
  //business
  //...
}

Configuration Example

appsettings.json:

{
  "AppControllerConfig": {
    "ControllerFirstPrefix": "yyt",
    "ControllerSecondPrefix": ""
  },
  "ImagePath": {
    "Web": "/file",
    "Mobile": "/file"
  }
}

Chinese Version

概述

Yyt.Abp.ApiController 是一个轻量级库,旨在简化 .NET 应用程序中的 API 路由、标准化输入/输出参数格式,并简化静态图片配置,全局标准化异常处理,Version 1.0.3 移除addmvc配置调整为addcontroller,Version 1.0.6 增加了对net8和net10的支持。采用模块化架构设计,可无缝集成到现有项目中。该库由 Patrick.Z 提供支持,减轻了重复的日常开发配置负担,让您能够专注于核心业务逻辑。

为什么选择 Yyt.Abp.ApiController?

  • 极少依赖:轻量级设计,外部依赖少,确保高性能和易于集成
  • 设计安全:遵循安全最佳实践,保护您的应用程序端点
  • 高度可扩展:灵活的架构允许轻松定制以满足高级用例
  • 久经沙场:通过多个生产项目验证,可靠性久经考验

主要功能

1. 简化静态图片配置

自动映射 wwwroot\images 中的图片路径,为 MobileWeb 客户端提供独立配置。注意,项目根目录必须要有wwwroot/image目录文件夹。

访问示例http://file/{imageUrl}

2. 灵活的 API 路由前缀重写

支持自定义重写 API 路由的一级和二级前缀。例如,如果一级前缀配置为 yyt。 ExcludeFromRouteRewrit特性将不会执行一二级路由规则

访问示例http://xxx/yyt/api/login

3. 自动参数格式化

开箱即用地标准化 API 通信格式:

  • 命名约定:自动将所有 API 输入和输出参数转换为 camelCase
  • 日期格式:将日期时间对象标准化为标准格式 yyyy-MM-dd HH:mm:ss
4.全局自定义异常处理并标准化信息输出

统一异常返回示例


{
	"data": "error msg ...",
	"code": 0,
	"msg": "",
	"success": true,
	"timestamp": 1782177092999
}

配置示例

namespace Demo.HttpApi.Host
{
    [DependsOn(
      typeof(VoloApiControllerModule)
    )]
    public class DemoHttpApiHostModule : AbpModule
    {
        // config service & other
    }
}

ExcludeFromRouteRewrit排除特性代码示例:


[HttpPost]
[Route("add")]
[ExcludeFromRouteRewrit]
public async Task<ServiceResult<string>> AddData(AddDataInput input)
{
	  //business
	  //...
}

配置示例

appsettings.json

{
  "AppControllerConfig": {
    "ControllerFirstPrefix": "yyt",
    "ControllerSecondPrefix": ""
  },
  "ImagePath": {
    "Web": "/file",
    "Mobile": "/file"
  }
}

Document Version: v1.0
Created Date: June 2026
Author: Patrick.Z

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 (1)

Showing the top 1 NuGet packages that depend on Yyt.Abp.ApiController:

Package Downloads
Yyt.Abp.HwSdk

It is a library that provides the functionality to simplify the integration of SDC camera devices and LVS video storage devices in the HWSdk protocol for .NET applications,Version 1.0.2 added support for net8. Built with a modular architecture, it enables seamless integration into your existing projects. Maintained and supported by Patrick.Z, it streamlines routine development configurations in .NET applications and takes over heavy, tedious workloads for you.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 67 9/1/2026
1.0.4 126 8/25/2026
1.0.3 180 6/30/2026
1.0.2 108 6/23/2026
1.0.0 143 6/9/2026