Docs
Tenantry CoreAPI reference

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 ITenantResolver

Derived 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:

  • context HttpContext: The current HTTP context.
  • cancellationToken CancellationToken: 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.

On this page