Asgard.AspNetCore.Core 7.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Asgard.AspNetCore.Core --version 7.2.0
                    
NuGet\Install-Package Asgard.AspNetCore.Core -Version 7.2.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="Asgard.AspNetCore.Core" Version="7.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Asgard.AspNetCore.Core" Version="7.2.0" />
                    
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 7.2.0
                    
#r "nuget: Asgard.AspNetCore.Core, 7.2.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 Asgard.AspNetCore.Core@7.2.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=Asgard.AspNetCore.Core&version=7.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Asgard.AspNetCore.Core&version=7.2.0
                    
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 解析
  • 内置函数:contains、startsWith、exists
  • 默认空实现的 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.Abstractions、Asgard.Abstractions.AspNetCore
  • 基础设施实现:Asgard.Core
  • 完整主机体验:Asgard.Yggdrasil.AspNetCore

相关资源

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
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 主机层,集成 OpenAPI、Scalar、数据保护、日志和核心服务。

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.1.0 0 11/19/2026
8.0.0 6 11/19/2026
7.2.0 69 11/17/2026
7.1.0 64 11/17/2026
7.0.0 82 11/13/2026
6.1.0 143 11/6/2026
6.0.4 151 10/24/2026
6.0.3 164 10/11/2026
6.0.2 141 10/8/2026
6.0.1 122 10/8/2026
6.0.0 129 10/1/2026
5.3.0 193 10/1/2026
5.2.3 126 10/1/2026
5.2.2 149 9/1/2026
5.2.1 146 8/26/2026
5.2.0 210 8/6/2026
5.1.5 171 8/4/2026
5.1.4 157 8/3/2026
5.1.3 154 7/26/2026
5.1.2 191 7/20/2026
Loading failed