Asgard.AspNetCore.Core
4.1.1
dotnet add package Asgard.AspNetCore.Core --version 4.1.1
NuGet\Install-Package Asgard.AspNetCore.Core -Version 4.1.1
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="4.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Asgard.AspNetCore.Core" Version="4.1.1" />
<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 4.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Asgard.AspNetCore.Core, 4.1.1"
#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@4.1.1
#: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=4.1.1
#tool nuget:?package=Asgard.AspNetCore.Core&version=4.1.1
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 (>= 4.1.1)
- Asgard.Abstractions.AspNetCore (>= 4.1.1)
- Asgard.Core (>= 4.1.1)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.9)
- Microsoft.Extensions.DependencyInjection (>= 10.0.5)
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 |
|---|---|---|
| 4.1.1 | 44 | 4/15/2026 |
| 4.1.0 | 47 | 4/14/2026 |
| 4.0.5 | 57 | 4/11/2026 |
| 4.0.4 | 61 | 4/10/2026 |
| 4.0.3 | 87 | 4/9/2026 |
| 4.0.2 | 98 | 4/8/2026 |
| 4.0.1 | 110 | 4/3/2026 |
| 4.0.0 | 116 | 4/1/2026 |
| 4.0.0-preview.7 | 53 | 3/31/2026 |
| 4.0.0-preview.6 | 49 | 3/30/2026 |
| 4.0.0-preview.5 | 137 | 3/28/2026 |
| 4.0.0-preview.4 | 52 | 3/27/2026 |
| 4.0.0-preview.3 | 49 | 3/27/2026 |
| 4.0.0-preview.2 | 42 | 3/27/2026 |
| 4.0.0-preview.1 | 50 | 3/27/2026 |