Open Closed

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


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+&lt;AwaitTaskWithPostActionAndFinallyAndGetResult&gt;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+&lt;&gt;c__DisplayClass0_0+&lt;&lt;UseJwtTokenMiddleware&gt;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+&lt;&gt;c__DisplayClass0_0+&lt;&lt;UseJwtTokenMiddleware&gt;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)
  • 0
    maliming created

    hi @banksearch

    • What is your zero version?
    • What are the steps to reproduce the problem?
  • 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.
  • 0
    maliming created

    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.

  • 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

  • 0
    maliming created

    Is it convenient to share your project source code? My email: liming.ma@volosoft.com

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

    var user = await _userManager.FindByIdAsync(cacheItem.TargetUserId.ToString());
    
  • 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.

  • 0
    maliming created

    Is the application using memory caching or Redis?

    Can you try to clear the cache?

  • 0
    banksearch created

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

  • 0
    maliming created

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

    Such as the GetSwitchedUserAndIdentity method switchAccountToken cacheItem.ToJsonString()

  • 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?

  • 0
    maliming created

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