Base solution for your next web application
Open Closed

Update Custom Claim in Session Not Working #10418


User avatar
1
ricardo created
  • What is your product version : v10.0.0
  • What is your product type (Angular or MVC): MVC
  • What is product framework type (.net framework or .net core): .net Core
  1. I created custom session using claim:

created CreateAsync override in UserClaimsPrincipalFactory.cs

  1. created MySession:

  2. during execution in a drop down the user can select another value.

after login the value is correctly updated in CurrentUnidaNegocioAtivaIdOrNull in the session. But when the user makes the change via SetUnidadeNegocioAtiva, the value is not replicated to the session. Only after the second post to the server is it able to fetch the value correctly.

Debug:

Is there any way for the value to be instantly updated in the session? Where can I be wrong?


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

    Hi,

    I guess, the claims on the cookie is not updated this way. Could you try using teh code below ?

    await signInManager.SignOutAsync();
    await signInManager.SignInAsync(user, false);
    
  • User Avatar
    0
    ricardo created

    Worked perfectly. Thank you very much for the quick feedback.