NICWebApi.Extensions.AspNetCore 1.0.41

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

NICWebApi.Extensions.AspNetCore

ASP.NET Core 一键集成包,组合常用扩展的默认注册:

  • DynamicAPI
  • RESTfulResult
  • JWT
  • Mapper
  • DependencyInjection
  • Http
  • RemoteRequest
  • Caching
  • Idempotency
  • Schedule
  • Messaging
  • OperationLogging

安装

dotnet add package NICWebApi.Extensions.AspNetCore

使用

var builder = WebApplication.CreateBuilder(args);

builder.Services
    .AddControllers()
    .AddNICWebApiExtensions();

var app = builder.Build();

app.UseNICWebApiExtensions();
app.MapControllers();
app.Run();

可选配置

不传 IConfiguration 时,会优先使用 DI 中已有的配置;如果没有配置实例,则使用空配置和各模块默认值。 扩展自身能力默认开启,用户显式配置优先;Redis、生产密钥、第三方地址等外部资源仍需显式配置。 UseNICWebApiExtensions 只会挂载已经注册了对应服务的中间件,因此显式关闭模块后默认管道不会重新启用它。

{
  "NICWebApiExtensions": {
    "EnableDynamicApi": true,
    "EnableRESTfulResult": true,
    "EnableJwtAuthentication": true,
    "EnableCaching": true,
    "EnableIdempotency": true,
    "EnableMessaging": true,
    "EnableOperationLogging": true,
    "EnableSchedule": true,
    "Application": {
      "UseScheduleUI": true,
      "UseOperationLogging": true
    }
  },
  "RemoteRequest": {
    "BaseAddress": "https://api.example.com",
    "Timeout": "00:00:10"
  },
  "Caching": {
    "DefaultExpiration": "00:20:00",
    "Redis": {
      "Enabled": false,
      "Configuration": "localhost:6379",
      "InstanceName": "my-api:"
    }
  },
  "Idempotency": {
    "HeaderName": "Idempotency-Key",
    "Expiration": "00:10:00",
    "Redis": {
      "Enabled": false,
      "Configuration": "localhost:6379"
    }
  },
  "Messaging": {
    "Capacity": 1000,
    "ConsumerCount": 1,
    "MaxRetryCount": 3,
    "Redis": {
      "Enabled": false,
      "Configuration": "localhost:6379",
      "QueueKey": "my-api:messaging:queue"
    }
  },
  "OperationLogging": {
    "Provider": "Text",
    "TableName": "OperationLogs",
    "Text": {
      "Directory": "OperationLogs"
    },
    "Dashboard": {
      "Enabled": null,
      "Path": "/operation-logs",
      "PageSize": 50
    },
    "Capture": {
      "RequestQuery": true,
      "RequestBody": false,
      "ResponseBody": false,
      "MaxBodyLength": 8192
    },
    "CaptureRemoteRequests": true
  },
  "Schedule": {
    "Redis": {
      "Enabled": false,
      "Configuration": "localhost:6379",
      "KeyPrefix": "my-api:schedule:lock:"
    }
  }
}
builder.Services
    .AddControllers()
    .AddNICWebApiExtensions(options =>
    {
        options.Caching = cache => cache.UseRedis("localhost:6379", "my-api:");
        options.Idempotency = idempotency => idempotency.UseRedis("localhost:6379");
        options.Messaging = messaging => messaging.UseRedis("localhost:6379", "my-api:messaging:queue");
        options.Schedule = schedule => schedule.UseRedis("localhost:6379", "my-api:schedule:lock:");
        options.DynamicApi = api =>
        {
            api.Swagger.Title = "My API";
            api.Swagger.RoutePrefix = "swagger";
        };
    });

生产环境使用 JWT 时,请覆盖 JWT:IssuerSigningKey,不要使用默认开发密钥。

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.41 158 7/7/2026