FBW.DotNet.AspNetCore 1.0.5

dotnet add package FBW.DotNet.AspNetCore --version 1.0.5                
NuGet\Install-Package FBW.DotNet.AspNetCore -Version 1.0.5                
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="FBW.DotNet.AspNetCore" Version="1.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FBW.DotNet.AspNetCore --version 1.0.5                
#r "nuget: FBW.DotNet.AspNetCore, 1.0.5"                
#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.
// Install FBW.DotNet.AspNetCore as a Cake Addin
#addin nuget:?package=FBW.DotNet.AspNetCore&version=1.0.5

// Install FBW.DotNet.AspNetCore as a Cake Tool
#tool nuget:?package=FBW.DotNet.AspNetCore&version=1.0.5                

FBW.DotNet.AspNetCore

ASP.NET Core扩展包,目前支持.NET3.1,.NET5,.NET6,.NET7,.NET8

如何使用

1、安装FBW.DotNet.AspNetCore依赖。
Cmd install:

dotnet add package FBW.DotNet.AspNetCore

2、在Startup.cs中配置

//Identity相关配置
builder.Services.AddDefaultIdentityConfiguration().AddIdentityNpgsqlStore(new IdentityOptions(
    configuration["SystemConfig:DBConnectionString"],
    configuration["SystemConfig:PrivateKey"],
    configuration.GetSection("RedisConfig").Get<RedisOptions>()
)).AddResourceOwnerValidator<ResourceOwnerPasswordValidator>();

//jwt相关配置
builder.Services.AddDotNetJwtBearerAuthentication(configuration["SystemConfig:PublicKey"],configuration["SystemConfig:ValidIssuer"]);

//Mvc相关配置
builder.Services.AddDotNetDefaultMvc();

//SwaggerDoc配置
builder.Services.AddSwaggerDoc(configuration.GetSection("SwaggerConfig").Get<SwaggerConfig>());

var app = builder.Build();

app.UseDotNetDefaultMvc();
app.UseSwaggerUI(configuration.GetSection("SwaggerConfig").Get<SwaggerConfig>());
app.UseIdentityServer();

3、 appsettings.json配置文件实例:

{
   //接口文档配置
  "SwaggerConfig": {
    "Title": "DotNet.Admin.Web",
    "Version": "v1",
    "Description": "DotNet.Admin.Web",
    "Name": "DotNet",
    "Email": "2231030106@qq.com",
    "ProxyRoutes": {
      //"localhost": "http://127.0.0.1:6033/IdentityServer"
    }
  },
  //redis 配置
  "RedisConfig": {
    "Connection": "127.0.0.1:6379,password=123456",
    "KeyPrefix": "dotnetadminweb",
    "DefaultDatabase": 0,
    "DataProtecteKey": "DotNet.Admin.Web:DataProtection-Keys",
    "IsSentinel": false, // 是否哨兵模式
    "SentinelConfig": {
        "DefaultDatabase": "4",
        "EndPoints": [ // 哨兵端口
        // "10.10.0.124:26380"
        ],
        "Password": "123456",
        "SentinelPassword": "123456",
        "ServiceName": "dotnetadminweb"
    }
  },
   //系统配置
  "SystemConfig": {
    "ValidIssuer": "https://localhost:44354",
    "DatabaseVisitLogSleep": 10000,//系统日志入库时间
    "DBConnectionString": "Host=127.0.0.1;Username=postgres;Password=123456;Database=DotNet_Template",
    "PublicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiQPMKq+BQIhoImH30v8FH02x8S8Bz6+ROwzidBEk8C2BidnnMFs2OeXQeHRW7HSJRAhTVTBwhWoJ+3G/C2L6FiMLYPgaKpWsacqZPkbcgpHKfQLJn1weXeZqLNeZKi+aebOX27JOt9cph/YVb5hBTgVzl5q7yASOEg9+wV/y1d8Jq4EAlzXdAux+JRgMGQgj8CSPSSY1z2PO4iZProdgFa/dto8AlVRabVCTx6BoCnMrImy2XRHdF0Ue0eY5mtAAsnLudjKqm8AUopMOivNCLVI5eXzMIoMmpa0bUj7IluoushYVLY0dw7flyKldiDbyvi4w/jrxHRruNMb11fNEFQIDAQAB",
    "PrivateKey": "MIIEowIBAAKCAQEAiQPMKq+BQIhoImH30v8FH02x8S8Bz6+ROwzidBEk8C2BidnnMFs2OeXQeHRW7HSJRAhTVTBwhWoJ+3G/C2L6FiMLYPgaKpWsacqZPkbcgpHKfQLJn1weXeZqLNeZKi+aebOX27JOt9cph/YVb5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PEs2xtIQlBoCV0F5jsj41D5LCY7qqBBJ0JQv/DumbMi8jl5f8p+9tVlDI8eP5wXPC1v8TZX4Zv1KVmZnnGUIDaD9HcE5a76nEKIaZDJCtBVc6+GdDMzj45wGgIr6sTuVPPD6R0xEtLrVMaIke6cvXV1GnBudTw18L8Vn2YnSBQKBgG/NxXjh+urIa+qsIzNHbrTCt+qGsix8z1f7s1OwTlVksFW3otaNK2hIDMlslUgRnVzjZfPyzKME/EuA/WjqAn/ZxqDR1TYvgxil8EaBn9jTEL7LO06ggCuh1dnmPrzC06no5E6Gj4m+6tknO5K5/NU/2HqQnaR6IB514ut7URba"
  }
}

4、Efcore迁移

add-migration Ids4Config001 -c IdentityContext -o Migrations/Ids4Config 
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  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 is compatible.  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. 
.NET Core netcoreapp3.1 is compatible. 
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.5 100 8/22/2024
1.0.4 105 8/22/2024 1.0.4 is deprecated because it has critical bugs.
1.0.3 114 8/21/2024 1.0.3 is deprecated because it is no longer maintained.
1.0.2 96 5/22/2024
1.0.1 150 1/12/2024
1.0.0 88 1/12/2024