登录后未填充HttpContext.Current.User.Identity

时间:2017-09-22 19:01:02

标签: vb.net asp.net-identity

所以我正在使用AspNet Identity,并且我正在尝试在登录后访问Http.Context.Current.User中的用户会话变量。我在网上看到,一旦登录尝试成功,它应该自动填充。然而,对我来说似乎并非如此。

这是我的代码:

  Dim email As String = txtEmail.Text
            Dim password As String = txtPassword.Text
            Dim user As ApplicationUser

            If Session("LocalNetwork") Then
                Await _signInManager.PasswordSignInAsync(email, password, False, False))

                Dim y = HttpContext.Current.User.Identity.GetUserId

            End If

登录成功,我正在尝试访问我的UsersID,但它返回null。

网络配置:

<authentication mode="None" />

任何人都知道为什么?

1 个答案:

答案 0 :(得分:1)

这是因为我正在检查用户是否在更新它们的同一请求中进行了身份验证。因此,在请求结束之前,它们不会被验证。