Asgard.AspNetCore.Core 5.1.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package Asgard.AspNetCore.Core --version 5.1.3
                    
NuGet\Install-Package Asgard.AspNetCore.Core -Version 5.1.3
                    
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="Asgard.AspNetCore.Core" Version="5.1.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Asgard.AspNetCore.Core" Version="5.1.3" />
                    
Directory.Packages.props
<PackageReference Include="Asgard.AspNetCore.Core" />
                    
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 Asgard.AspNetCore.Core --version 5.1.3
                    
#r "nuget: Asgard.AspNetCore.Core, 5.1.3"
                    
#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 Asgard.AspNetCore.Core@5.1.3
                    
#: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=Asgard.AspNetCore.Core&version=5.1.3
                    
Install as a Cake Addin
#tool nuget:?package=Asgard.AspNetCore.Core&version=5.1.3
                    
Install as a Cake Tool

Asgard.AspNetCore.Core

Asgard.AspNetCore.Core 是 Asgard 的 ASP.NET Core 运行时集成包,负责把核心能力接入 Web 应用,包括中间件、身份上下文、租户处理和 AsgardAuth 权限运行时。

如果你要在自己的 ASP.NET Core 应用里按模块化方式接入 Asgard,但不一定要直接使用完整宿主模板,这个包通常是最合适的运行时入口。

适用场景

  • 基于 Asgard.Core 构建 ASP.NET Core 应用
  • 需要 Asgard 的租户处理中间件和身份上下文能力
  • 需要启用 AsgardAuth 的权限解析与执行
  • 想自己控制 Program.cs 和中间件顺序

包含内容

  • 租户感知中间件和租户作用域能力
  • HTTP 身份上下文访问器和默认解析器
  • ASP.NET Core 服务注册扩展
  • AsgardAuth 运行时求值、DSL 解析、内置函数和扩展点

安装

dotnet add package Asgard.AspNetCore.Core

快速开始

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddAsgardContext();
builder.Services.AddAsgardAspNetCore();

var app = builder.Build();
app.UseAuthentication();
app.UseAsgardTenant();
app.UseAuthorization();
app.MapControllers();

AsgardAuth 运行时

AddAsgardAspNetCore() 会自动注册 AsgardAuth 相关运行时能力,包括:

  • AsgardAuthRequirement
  • AsgardAuthHandler
  • AsgardAuthAnd / AsgardAuthOr 的顺序表达式拼装
  • AsgardAuthMatch 的 DSL 解析
  • 内置函数:containsstartsWithexists
  • 默认空实现的 IAsgardAuthDataResolver

业务代码只需要在控制器或 Action 上声明 AsgardAuth* 特性:

[Authorize]
[AsgardAuthAnyRole("admin")]
[AsgardAuthOr]
[AsgardAuthUserMetadataEquals("department", "platform")]
public ActionResult<string> Get()
    => Ok("ok");

你也可以注册自定义函数和数据解析器:

builder.Services.AddSingleton<IAsgardAuthFunction, CustomDepartmentFunction>();
builder.Services.AddSingleton<IAsgardAuthDataResolver, MyAsgardAuthDataResolver>();

推荐搭配

  • 契约层:Asgard.AbstractionsAsgard.Abstractions.AspNetCore
  • 基础设施实现:Asgard.Core
  • 完整主机体验:Asgard.Yggdrasil.AspNetCore

相关资源

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 (1)

Showing the top 1 NuGet packages that depend on Asgard.AspNetCore.Core:

Package Downloads
Asgard.Yggdrasil.AspNetCore

Asgard.Yggdrasil.AspNetCore 是 Asgard 框架的 ASP.NET Core 主机层,提供完整的 Web 应用程序启动模板,集成了Swagger、数据保护、日志和所有核心服务,帮助快速构建模块化应用。

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.2.0 84 8/6/2026
5.1.5 101 8/4/2026
5.1.4 116 8/3/2026
5.1.3 112 7/26/2026
5.1.2 161 7/20/2026
5.1.1 116 7/20/2026
5.1.0 113 7/20/2026
5.0.3 119 7/15/2026
5.0.2 124 7/15/2026
5.0.1 132 7/8/2026
4.1.11 141 6/30/2026
4.1.10 123 6/28/2026
4.1.9 133 6/7/2026
4.1.8 333 5/31/2026
4.1.7 135 5/24/2026
4.1.6 129 5/24/2026
4.1.5 130 5/23/2026
4.1.4 141 5/16/2026
4.1.3 134 4/28/2026
4.1.2 142 4/21/2026
Loading failed