Asgard.AspNetCore.Core
5.2.0
dotnet add package Asgard.AspNetCore.Core --version 5.2.0
NuGet\Install-Package Asgard.AspNetCore.Core -Version 5.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="5.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="5.2.0" />
<PackageReference Include="Asgard.AspNetCore.Core" />
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.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Asgard.AspNetCore.Core, 5.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@5.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=5.2.0
#tool nuget:?package=Asgard.AspNetCore.Core&version=5.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 相关运行时能力,包括:
AsgardAuthRequirementAsgardAuthHandlerAsgardAuthAnd/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
相关资源
- 主仓库:BenLampson/Asgard
AsgardAuth文档:AsgardAuth.md- Asgard Skills 仓库:BenLampson/Asgard.Skills
| Product | Versions 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.
-
net10.0
- Asgard.Abstractions (>= 5.2.0)
- Asgard.Abstractions.AspNetCore (>= 5.2.0)
- Asgard.Core (>= 5.2.0)
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 | 82 | 8/6/2026 |
| 5.1.5 | 100 | 8/4/2026 |
| 5.1.4 | 115 | 8/3/2026 |
| 5.1.3 | 111 | 7/26/2026 |
| 5.1.2 | 161 | 7/20/2026 |
| 5.1.1 | 116 | 7/20/2026 |
| 5.1.0 | 112 | 7/20/2026 |
| 5.0.3 | 119 | 7/15/2026 |
| 5.0.2 | 123 | 7/15/2026 |
| 5.0.1 | 132 | 7/8/2026 |
| 4.1.11 | 140 | 6/30/2026 |
| 4.1.10 | 122 | 6/28/2026 |
| 4.1.9 | 132 | 6/7/2026 |
| 4.1.8 | 331 | 5/31/2026 |
| 4.1.7 | 134 | 5/24/2026 |
| 4.1.6 | 129 | 5/24/2026 |
| 4.1.5 | 129 | 5/23/2026 |
| 4.1.4 | 140 | 5/16/2026 |
| 4.1.3 | 134 | 4/28/2026 |
| 4.1.2 | 141 | 4/21/2026 |
Loading failed