Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

error when switch from tenant to host website by linked account #7324


User avatar
0
banksearch created

when login to demo tenant, and switch to host website as below: will get error page: below is the error details: System.ArgumentNullException: Value cannot be null. Parameter name: user Module "Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory1", in CreateAsync Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification Module "Abp.Authorization.AbpUserClaimsPrincipalFactory2", in CreateAsync Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification Module "Abp.Threading.InternalAsyncHelper+<AwaitTaskWithPostActionAndFinallyAndGetResult>d__51", in MoveNext Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification File "d:\a\1\s\src\GrowMyCompany.Core\Authorization\Users\UserLinkManager.cs", line 123, col 13, in GetSwitchedUserAndIdentity Void MoveNext() Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification File "d:\a\1\s\src\GrowMyCompany.Web.Mvc\Controllers\AccountController.cs", line 847, col 13, in SwitchToLinkedAccountSignIn Void MoveNext() Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification Module "Abp.Threading.InternalAsyncHelper+<AwaitTaskWithPostActionAndFinallyAndGetResult>d__51", in MoveNext Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification Module "(unknown)", in lambda_method Module "Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable+Awaiter", in GetResult Module "Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker", in InvokeActionMethodAsync Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification Module "Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker", in InvokeNextActionFilterAsync Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker", in Rethrow Module "Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker", in Next Module "Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker", in InvokeInnerFilterAsync Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification Module "Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker", in InvokeNextExceptionFilterAsync Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker", in Rethrow Module "Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker", in Next Module "Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker", in InvokeNextResourceFilter Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker", in Rethrow Module "Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker", in Next Module "Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker", in InvokeFilterPipelineAsync Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification Module "Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker", in InvokeAsync Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification Module "Microsoft.AspNetCore.Builder.RouterMiddleware", in Invoke Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification Module "Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware", in Invoke Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification Module "IdentityServer4.Hosting.IdentityServerMiddleware", in Invoke Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification Module "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", in Invoke Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification Module "Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware", in Invoke Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification Module "IdentityServer4.Hosting.BaseUrlMiddleware", in Invoke Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification Module "Abp.AspNetZeroCore.Web.Authentication.JwtBearer.JwtTokenMiddleware+<>c__DisplayClass0_0+<<UseJwtTokenMiddleware>b__0>d", in MoveNext Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification Module "Abp.AspNetZeroCore.Web.Authentication.JwtBearer.JwtTokenMiddleware+<>c__DisplayClass0_0+<<UseJwtTokenMiddleware>b__0>d", in MoveNext Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification Module "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", in Invoke Module "System.Runtime.ExceptionServices.ExceptionDispatchInfo", in Throw Module "System.Runtime.CompilerServices.TaskAwaiter", in ThrowForNonSuccess Module "System.Runtime.CompilerServices.TaskAwaiter", in HandleNonSuccessAndDebuggerNotification Module "Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware", in Invoke

we have not change the security code for user login and switch to link user, do you know what is the problem?


11 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    hi @banksearch

    • What is your zero version?
    • What are the steps to reproduce the problem?
  • User Avatar
    0
    banksearch created

    hi, @maliming how to check my zero version?

    to produce the problem

    1. login to tenant website as tenant admin.
    2. right click on the menu in the topright.
    3. select the link from linked users, which refer to the host user.
    4. website try to direct to the host website, and get the error/exception page.
  • User Avatar
    0
    maliming created
    Support Team

    Please check the version in the \aspnet-core\src\MyCompanyName.AbpZeroTemplate.Core\AppVersionHelper.cs file.

    I can't seem to reproduce your problem with 7.0.

  • User Avatar
    0
    banksearch created

    HI @maliming We have version 5.1 https://docs.aspnetzero.com/documents/common/latest/Change-Logs#v5-1-0-2018-02-05

  • User Avatar
    0
    maliming created
    Support Team

    Is it convenient to share your project source code? My email: [email protected]

    Or set breakpoint debugging in the GetSwitchedUserAndIdentity method to see why user is null

    var user = await _userManager.FindByIdAsync(cacheItem.TargetUserId.ToString());
    
  • User Avatar
    0
    banksearch created

    we try to debug the project in local machine, and add break point to the GetSwitchedUserAndIdentity method, it is working when debug it, the user can load without any problem, but when we deploy the code to Azure, the problem happen.

    PS: we target to the same azure db when we debug in local.

  • User Avatar
    0
    maliming created
    Support Team

    Is the application using memory caching or Redis?

    Can you try to clear the cache?

  • User Avatar
    0
    banksearch created

    HI @maliming we use memory caching, and we have try to clear teh cache, but still have the problem.

  • User Avatar
    0
    maliming created
    Support Team

    Can you write some messages from the production environment to the log?

    Such as the GetSwitchedUserAndIdentity method switchAccountToken cacheItem.ToJsonString()

  • User Avatar
    0
    banksearch created

    below is the code have the problem: it looks like the user is not load correctly by the TargetUserId. we have not change the security code for user login and switch to link user, do you know what is the problem?

  • User Avatar
    0
    maliming created
    Support Team

    Is cacheItem.TargetUserId a valid UserId when the application is running at azure?