CleanArchitecture.Extensions.Multitenancy.AspNetCore
0.2.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package CleanArchitecture.Extensions.Multitenancy.AspNetCore --version 0.2.1
NuGet\Install-Package CleanArchitecture.Extensions.Multitenancy.AspNetCore -Version 0.2.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="CleanArchitecture.Extensions.Multitenancy.AspNetCore" Version="0.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CleanArchitecture.Extensions.Multitenancy.AspNetCore" Version="0.2.1" />
<PackageReference Include="CleanArchitecture.Extensions.Multitenancy.AspNetCore" />
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 CleanArchitecture.Extensions.Multitenancy.AspNetCore --version 0.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CleanArchitecture.Extensions.Multitenancy.AspNetCore, 0.2.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 CleanArchitecture.Extensions.Multitenancy.AspNetCore@0.2.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=CleanArchitecture.Extensions.Multitenancy.AspNetCore&version=0.2.1
#tool nuget:?package=CleanArchitecture.Extensions.Multitenancy.AspNetCore&version=0.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
CleanArchitecture.Extensions.Multitenancy.AspNetCore
ASP.NET Core adapter for CleanArchitecture.Extensions.Multitenancy. It provides middleware to resolve tenants from HTTP requests, endpoint filters for enforcement, and helpers for minimal APIs and MVC.
What you get
- Tenant resolution middleware that builds
TenantResolutionContextfromHttpContext. - Minimal API endpoint filter (
TenantEnforcementEndpointFilter). - MVC action filter (
TenantEnforcementActionFilter). - Endpoint metadata helpers (
RequireTenant,AllowAnonymousTenant,WithTenantHeader,WithTenantRoute). - ProblemDetails mapping for multitenancy exceptions.
Install
dotnet add package CleanArchitecture.Extensions.Multitenancy.AspNetCore
Quickstart
1) Register services
using CleanArchitecture.Extensions.Multitenancy.AspNetCore;
builder.Services.AddCleanArchitectureMultitenancyAspNetCore();
2) Add the middleware
using CleanArchitecture.Extensions.Multitenancy.AspNetCore.Middleware;
app.UseCleanArchitectureMultitenancy();
3) Enforce tenancy (minimal APIs)
using CleanArchitecture.Extensions.Multitenancy.AspNetCore.Routing;
app.MapGroup("/tenants/{tenantId}")
.AddTenantEnforcement()
.RequireTenant()
.MapGet("/profile", () => Results.Ok());
4) Enforce tenancy (MVC)
using CleanArchitecture.Extensions.Multitenancy.AspNetCore;
builder.Services
.AddControllers()
.AddMultitenancyEnforcement();
Options
using CleanArchitecture.Extensions.Multitenancy.AspNetCore;
using CleanArchitecture.Extensions.Multitenancy.AspNetCore.Options;
using CleanArchitecture.Extensions.Multitenancy.Configuration;
builder.Services.AddCleanArchitectureMultitenancyAspNetCore(
coreOptions =>
{
coreOptions.HeaderNames = new[] { "X-Tenant-ID" };
coreOptions.RouteParameterName = "tenantId";
coreOptions.QueryParameterName = "tenantId";
},
aspNetOptions =>
{
aspNetOptions.CorrelationIdHeaderName = "X-Correlation-ID";
aspNetOptions.StoreTenantInHttpContextItems = true;
});
ProblemDetails mapping
Use TenantProblemDetailsMapper when you want to turn multitenancy exceptions into HTTP responses:
using CleanArchitecture.Extensions.Multitenancy.AspNetCore.ProblemDetails;
if (TenantProblemDetailsMapper.TryCreate(exception, httpContext, out var details))
{
return Results.Problem(details);
}
Notes
- This adapter depends on the core multitenancy package and wires its services automatically.
- MediatR behaviors still live in the core package (
AddCleanArchitectureMultitenancyPipeline). - The middleware stores the resolved
TenantContextinHttpContext.Itemsby default.
| 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
- CleanArchitecture.Extensions.Multitenancy (>= 0.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.