Base solution for your next web application
Open Closed

Multitenant impersonation issue #4667


User avatar
0
geertveenstra created

After deployment to IIS the tenant impersonation as a host user is not working correctly (if you return from the Tenant back to the Host).

I have the dynamic url set in the appsettings.production.json configuration file:
"WebSiteRootAddress": "https://{TENANCY_NAME}.domain.com/"
This is working ok, <a class="postlink" href="http://tenant1.domain.com">http://tenant1.domain.com</a> gives the tenant 1 part, <a class="postlink" href="http://tenant2.domain.com">http://tenant2.domain.com</a> gives the tenant2 part.
Also impersonation the tenant admin user is working correctly, but when returning to the host part, the url is <a class="postlink" href="http://domain.com/Account/ImpersonateSignIn?tokenId=3a7c88c3-2d2b-443a-b013-55d59898d5a2">http://domain.com/Account/ImpersonateSi ... d59898d5a2</a> and it gives an internal server error page.

In the logfile I can see the following error :
Mvc.ExceptionHandling.AbpExceptionFilter - Current tenant is different than given tenant. AbpSession.TenantId: 2, given tenantId:

Any idea how to fix this ?


10 Answer(s)
  • User Avatar
    0
    geertveenstra created

    I noticed that when the impersonation of a tenant user is done, there is a cookie placed in the root website which contains the imporonated Tenant Id.
    If I remove this cookie before returning to the host portal it's working ok ?

  • User Avatar
    0
    alper created
    Support Team

    the expected behavior of this scene
    1- you login as host (no tenant related cookies)
    2- you impersonate as one of the tenants (puts Abp.TenantId cookie)
    3- you revert back to host (removes Abp.TenantId)

    so in your case, if the cookie is not being removed when you turn back to host, you need to check it

  • User Avatar
    0
    geertveenstra created

    Thanx, but what would I check exactly ?

    I already mentioned I get an exception page on returning to the host.
    In the logfile I see the following error :

    Mvc.ExceptionHandling.AbpExceptionFilter - Current tenant is different than given tenant. AbpSession.TenantId: 2, given tenantId:

    Is the problem to be searched for in the aspnetzero code or in the boilerplate code ?
    I also wonder why the cookie is needed since it seems to be working also without it ?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @GeertVeenstra,

    What is your ABP and AspNet Zero versions ? As I remember there was a bug in one of the previous versions.

  • User Avatar
    0
    geertveenstra created

    Hi,

    I am testing on the latest zero version (5.1)

  • User Avatar
    0
    alper created
    Support Team

    <cite>GeertVeenstra: </cite>
    Thanx, but what would I check exactly ?

    I already mentioned I get an exception page on returning to the host.
    In the logfile I see the following error :

    Mvc.ExceptionHandling.AbpExceptionFilter - Current tenant is different than given tenant. AbpSession.TenantId: 2, given tenantId:

    Is the problem to be searched for in the aspnetzero code or in the boilerplate code ?
    I also wonder why the cookie is needed since it seems to be working also without it ?

    Check if the scenario is working as I told you.
    Is the abp.tenantId cookie being removed when you switch back to host

  • User Avatar
    0
    geertveenstra created

    The abp.tenant cookie is not deleted on returning to the host.

  • User Avatar
    0
    ismcagdas created
    Support Team

    @GeertVeenstra,

    A few questions;

    1. Can you write your project type ? ASP.NET Core & Angular, ASP.NET Core & jQuery or MVC 5.x ?

    2. Are you hoısting your app on azure or a local server ? If it is local, is it windows server or any other one ?

    3. Finally can you share your config files which contains website addresses via email with us ? You can send it to <a href="mailto:info@aspnetzero.com">info@aspnetzero.com</a>.

  • User Avatar
    0
    twig202 created

    I am having the same issue on the latest version of ASP.NET Zero. I am using ASP.NET Core jQuery version and it is hosted on Azure. Did you find a resolution to your issue? The cookie is not being deleted when I return to host.

  • User Avatar
    0
    ismcagdas created
    Support Team

    @twig202 could you share url config in appsettings.json ? have you used {TENANCY_NAME} placeholder ?