User.Identity.GetUserId() returns null after successful login

后端 未结 9 2557
傲寒
傲寒 2020-12-05 09:52

I\'ve defined a temp variable to get current user id, it always returns null.

Here is the snapshot:

Why?

UPDATE:

         


        
9条回答
  •  囚心锁ツ
    2020-12-05 10:19

    Here's what worked for me:

    await SignInManager.SignInAsync(user, isPersistent: true, rememberBrowser: false);
    
    AuthenticationManager.User = new GenericPrincipal(AuthenticationManager.AuthenticationResponseGrant.Identity, null);
    

    Once executed, you get authenticated state for the current request.

提交回复
热议问题