Open Closed

8.7.0 Problem using GetTenantLogoUrl when using {TENANCY_NAME} in appsettings WebSiteRootAddress #9270


0
geertveenstra created

Hi,

I am using the {TENANCY_NAME} in the url to set the tenant based on this url.

When I am sending an email, it looks like the GetTenantLogoUrl does not work correctly. The The webUrlService.GetServerRootAddress() always returns the url without the tenant name. So http://portal.com instead of https://tenant.portal.com

For now I fixed it by adding private string GetTenancyName(int? tenantId) { return tenantId.HasValue ? TenantCache.Get(tenantId.Value).TenancyName : null; } to the EmailTemplateProvider and GetServerRootAddress(GetTenancyName(tenantId))

Is there a more generic method to get the Tenancyname based on the TenantId, I noticed there is lots of places in the code where a private function is created to get the TenancyName ?

Geert Veenstra


4 Answer(s)
  • 0
    maliming created
    Support Team

    This seems to be a problem, I will check and fix it, thanks for your feedback.

    https://github.com/aspnetzero/aspnet-zero-core/pull/3393

  • 0
    geertveenstra created

    Hi Maliming,

    I see you already made a change to implement TenantManager. However when I make the same changes in the EmailTemplateProvider in my code I get the following exception on starting the application :

    Castle.MicroKernel.CircularDependencyException: 'Dependency cycle has been detected when trying to resolve component 'Portal.Authorization.Users.UserEmailer'. The resolution tree that resulted in the cycle is the following: Component 'Portal.Authorization.Users.UserEmailer' resolved as dependency of component 'Portal.MultiTenancy.TenantManager' resolved as dependency of component 'Portal.Net.Emailing.EmailTemplateProvider' resolved as dependency of component 'Portal.Authorization.Users.UserEmailer' resolved as dependency of component 'Abp.MultiTenancy.AbpTenantManager`2[[Portal.MultiTenancy.Tenant, Portal.Core, Version=8.7.0.0, Culture=neutral, PublicKeyToken=null],[Portal.Authorization.Users.User, Portal.Core, Version=8.7.0.0, Culture=neutral, PublicKeyToken=null]]_c27f9841-6f5e-424d-a9e8-5f4d4bf0c725' resolved as dependency of component 'Portal.MultiTenancy.TenantManager_92500322-0e0b-44d7-8311-3eb12de3148b' resolved as dependency of component 'Portal.MultiTenancy.SubscriptionExpirationCheckWorker' which is the root component being resolved. '

  • 0
    maliming created
    Support Team

    hi geertveenstra

    I will check.

    update: Please use ITenantCache : ) https://github.com/aspnetzero/aspnet-zero-core/pull/3394

  • 0
    geertveenstra created

    Yes, that's working :-)

    Thanks !