Base solution for your next web application
Open Closed

How to change tenant based on my requirements? #9557


User avatar
0
bulutyonetim created

Please answer the following questions before submitting an issue.

  • What is your product version? 9.0.1
  • What is your product type (Angular or MVC)? Angular (single solution)
  • What is product framework type (.net framework or .net core)? ASP.NET CORE

Hi,

I need to change tenant based on my requirements on only login page.

  • If URL does not contain any subdomain like mysite.com/account/login should sign in users into default tenant. I found that I can set the tenant to default on LoginService.ts like this
init(): void {
    abp.multiTenancy.setTenantIdCookie(1);
    ....
}
  • If URL contains any subdomain like tenantX.mysite.com/account/login should sign in users into tenantX Can you guid me how to do this?

1 Answer(s)
  • User Avatar
    0
    zony created
    Support Team

    I don't think any changes are needed, because ABP has implemented DomainTenantResolveContributor as the preferred resolver, and it will use your second-level domain name as the tenant name. If you want to implement your own resolution strategy, you only need to implement the ITenantResolveContributor interface, and then add it to the module's PreInitialize() method, like this.

    public class YourModule : AbpModule
    {
        public override void PreInitialize()
        {
            Configuration.MultiTenancy.Resolvers.Add<YourResolveContributor>();
        }
    }