Base solution for your next web application
Open Closed

Impersonation: AbpSession.ImpersonatorUserId is getting NULL #12073


User avatar
0
razkhan78 created

Hi Team,

We are upgrading our existing application (Asp.net Core MVC + Jquery with framework .net2.1 and version 6.2.1.) to .net 8 and version 13.1.1. following documentation (Version-Updating). We have successfully resolved all conflicts of files and now try to running the project.

When doing Impersonation getting a AbpSession.ImpersonatorUserId NULL.


10 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Is this happening on development time or production time ?

  • User Avatar
    0
    razkhan78 created

    Development time. As we are upgrading

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    In order to understand the problem, you can debug your project and first check https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Core/Authorization/Impersonation/ImpersonationManager.cs#L133 and see if the token is generated correctly.

    Then, when user is redirected to ImpersonateSignIn, you can check if the token is found in the cache or not here https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Mvc/Controllers/AccountController.cs#L1132

  • User Avatar
    0
    razkhan78 created

    Yes token are generating successfully and found in cache as well. We are using OpenIdDict.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Does it work if you disable OpenIddict ?

  • User Avatar
    0
    razkhan78 created

    I have tried with disable OpenIddict but still issue persists. After debug get to know PrincipalAccessor in ClaimsAbpSession getting all claims except ImpersonatorUserId claim in PrincipalAccessor.

  • User Avatar
    0
    razkhan78 created

    Hi Team, please respond.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @razkhan78

    This doesn't happen on a non-modified project. I assume a change on your project causes this problem but it is hard to understand it without seein your project. Please share how we can access your project with [email protected].

    Thanks,

  • User Avatar
    0
    razkhan78 created

    This problem has resolved. No response from your side since last 5 days so I tried with identityServer4 but using identityServer4 another issue came (upon login keeps redirecting back to login page and doesn't go to next page (HomeController -> Index page)). The ticket is open for this issue (https://support.aspnetzero.com/QA/Questions/11996/ASPNET-Zero-Upgrade-from-620-to-1311) please provide a solution for identityServer4 .

    So switching to identityServer4 and then come back to OpenIdDict, now value is coming in ImpersonatorUserId.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    We don't support IDSRV anymore and even IDSRV itself doesn't provide support. Why don't you consider moving to OpenIddict ? If there is a problem with that, we can try to guide you.