abpframework/abp · error · UserFriendlyException

Given tenant isn't available: {0}

Error message

Given tenant isn't available: {0}

What it means

Thrown by TenantSwitchModal.OnPostAsync right after the tenant is found: the tenant record exists but tenant.IsActive is false, meaning it has been deactivated. ABP prevents switching the current tenant context to an inactive tenant via the localized 'GivenTenantIsNotAvailable' message.

Source

Thrown at framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/TenantSwitchModal.cshtml.cs:58

            var tenant = await TenantStore.FindAsync(CurrentTenant.GetId());
            Input.Name = tenant?.Name;
        }
    }

    public virtual async Task OnPostAsync()
    {
        Guid? tenantId = null;
        if (!Input.Name.IsNullOrEmpty())
        {
            var tenant = await TenantStore.FindAsync(TenantNormalizer.NormalizeName(Input.Name!)!);
            if (tenant == null)
            {
                throw new UserFriendlyException(L["GivenTenantIsNotExist", Input.Name!]);
            }

            if (!tenant.IsActive)
            {
                throw new UserFriendlyException(L["GivenTenantIsNotAvailable", Input.Name!]);
            }

            tenantId = tenant.Id;
        }

        AbpMultiTenancyCookieHelper.SetTenantCookie(HttpContext, tenantId, Options.TenantKey);
    }

    public class TenantInfoModel
    {
        [InputInfoText("SwitchTenantHint")]
        public string? Name { get; set; }
    }
}

View on GitHub (pinned to 7ed43b1931)

Solutions

  1. Reactivate the tenant via the tenant management UI/API (set IsActive = true).
  2. Pick a different active tenant.
  3. Refresh the tenant list source so inactive tenants are no longer offered for switching.

Example fix

// before: switch to tenant that exists but IsActive == false -> not available
// after: activate the tenant first
await TenantManager.UpdateAsync(tenant.Id, x => x.IsActive = true);
Defensive patterns

Strategy: validation

Validate before calling

var tenant = await tenantStore.FindAsync(normalizedName);
if (tenant != null && !tenant.IsActive)
{
    // tell the user the tenant is inactive; don't attempt the switch
}

Type guard

null

Try / catch

try { await OnPostAsync(); }
catch (UserFriendlyException ex) when (ex.Code == "GivenTenantIsNotAvailable")
{ /* show localized 'tenant inactive' message */ }

Prevention

When it happens

Trigger: Posting the tenant-switch modal with a name that resolves to a tenant whose IsActive flag is false.

Common situations: Tenant was deactivated/suspended by an admin but still appears in a cached or stale dropdown; an automation script switches to a tenant that was recently disabled; tenant deactivated mid-session.

Related errors


AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13). Data as JSON: /api/errors/ec867f4867f28239. Report an issue: GitHub.