Open Closed

Can I hide the tenant switcher but still use the cookie resolver #10205


User avatar
0
FarReach.Greg created

I have custom code that sets the users tenant when they type in their username/email address. So I no longer need the tenant switcher. Currently I have javascript to hide this, but it still shows for a second before the javascript hides that element. If I remove all the resolvers, it obviously hides it but then the login functionality doesnt work

Configure<AbpTenantResolveOptions>(options => { options.TenantResolvers.Clear(); });

How can I keep the resolver functionality but just disable showing the tenant switcher


2 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    1. Solution
    • Keep your tenant resolvers (e.g., Cookie, Header, etc.) as-is. The tenant switcher UI is rendered by the theme’s Account layout. Override that layout and remove the switcher block so nothing flashes on first paint.

    • For LeptonX theme (most common in recent ABP versions), create the same-path view in your Web project and remove the tenant switcher section:

      Create file: Themes/LeptonX/Layouts/Account/Default.cshtml Copy the original content from the theme (you can scaffold it from the package or use the structure below) and delete the conditional that shows the tenant switch:

    @* Remove or comment out this entire block *@
      @* 
      @if (MultiTenancyOptions.Value.IsEnabled &&
           (TenantResolveResultAccessor.Result?.AppliedResolvers?.Contains(CookieTenantResolveContributor.ContributorName) == true ||
            TenantResolveResultAccessor.Result?.AppliedResolvers?.Contains(QueryStringTenantResolveContributor.ContributorName) == true))
      {
          <div>
              <div class="row">
                  <div class="col">
                      <span style="font-size: .8em;" class="text-uppercase text-muted">@MultiTenancyStringLocalizer["Tenant"]</span><br />
                      <h6 class="m-0 d-inline-block">
                          @if (CurrentTenant.Id == null)
                          {
                              <span>@MultiTenancyStringLocalizer["NotSelected"]</span>
                          }
                          else
                          {
                              <strong>@(CurrentTenant.Name ?? CurrentTenant.Id.Value.ToString())</strong>
                          }
                      </h6>
                  </div>
                  <div class="col-auto">
                      <a id="AbpTenantSwitchLink" href="javascript:;" class="btn btn-sm btn-outline-primary">@MultiTenancyStringLocalizer["Switch"]</a>
                  </div>
              </div>
          </div>
          <hr />
      }
      *@
    

    Leave the rest of the layout unchanged. This removes the tenant switcher UI entirely, so it won’t briefly appear, while your server-side tenant resolution (cookie resolver and any others) remains intact.

    • If you use the Basic theme or another theme, override its account layout in the equivalent path and remove the same tenant switcher section (it’s the same conditional block that checks MultiTenancyOptions and AppliedResolvers).

    • Do not clear AbpTenantResolveOptions unless you intend to replace all resolvers. Keep your cookie (and any other needed) resolvers registered so your custom logic that sets tenant (based on username/email) continues to work.

    1. Sources
    • Validated ABP Support answer showing how to override the LeptonX Account layout to customize/hide the tenant switcher:
      • https://abp.io/support/questions/9283

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can override the Account Layout to remove it.

    Where is your UI type and Theme?

    Thanks.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on December 10, 2025, 12:02
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.