ITenantResolver interface
Namespace: Tenantry.AspNetCore · Package: Tenantry.AspNetCore · API reference
Reads a tenant identifier from an HTTP request: the tenant's id, or a name the tenant store maps to a tenant, such as a subdomain or a host name (see ITenantStore<TKey>.FindByIdentifierAsync). Multiple resolvers can be registered; the middleware tries them in registration order and uses the first identifier one returns.
public interface ITenantResolverDerived types: ClaimTenantResolver, HeaderTenantResolver, HostTenantResolver, QueryStringTenantResolver, RouteValueTenantResolver, SubdomainTenantResolver.
Methods
ResolveAsync(HttpContext, CancellationToken)
Attempts to read a tenant identifier from the current request.
ValueTask<string?> ResolveAsync(HttpContext context, CancellationToken cancellationToken = default)Parameters:
contextHttpContext: The current HTTP context.cancellationTokenCancellationToken: Cancellation token.
Returns: ValueTask<string>: The identifier, or null (or an empty string) if this resolver cannot determine the tenant from the current request. Return it as the request carries it: the tenant store finds the tenant it names.