Open Closed

Can not change tenant if use AddDomainTenantResolver (UI already updated to show the tenant switch box) #1584


User avatar
0
christophe.baille created
  • ABP Framework version: v4.3.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

I added the follwing line on my **HttpApiHostModule class:

options.AddDomainTenantResolver("https://{0}:44348");

I then edited Default.cshtml file about keep seing the switch tenant box.

When I run my solution in local and go to my login page, I have the tenant localhost preseleted which is good.

My issue here is that if I try to change the tenant, once I click save, nothing happens, it keep localhost tenant. It goes through the method as I have the message "Given tenant is not available:..."

I added this lines in **HttpApiHostModule file but it remain the same

            options.TenantResolvers.Add(new QueryStringTenantResolveContributor());
            options.TenantResolvers.Add(new RouteTenantResolveContributor());
            options.TenantResolvers.Add(new HeaderTenantResolveContributor());
            options.TenantResolvers.Add(new CookieTenantResolveContributor());           

Is AddDomainTenantResolver supposed to change the behave of tenant resolve and not let use cookies anymore?


4 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Because the domain resolver has a higher priority than the cookie resolver.

  • User Avatar
    0
    christophe.baille created

    Thanks for the quick reply.

    So there is no way to change the tenant if it is auto selected by the domain? Can not change priority or anything?

    I wanted to let the user change it, specially in case the tenant with a given domain do not exists. I changed the TenantResolver.ResolveTenantIdOrNameAsync method to not throw an error, then I wanted let them select another one

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    I wanted to let the user change it, specially in case the tenant with a given domain do not exists

    Of course the user can change it when given domain do not exists. ABP will call the tenant resolver according to the priority until the resolution is successful.

    Can not change priority or anything?

    Yes you can :

    
    Configure<AbpTenantResolveOptions>(option =>
    {
        option.TenantResolvers.Insert(1, new CookieTenantResolveContributor());
    });
    
  • User Avatar
    0
    christophe.baille created

    Thanks, it works well now

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09