我正在使用 WebSecurity 和 SimpleMembershipProvider 来登录用户。
用户可以更改他们的电子邮件
Dim memberId As Integer = 1
Dim context As UsersContext = New UsersContext
Dim userProfile As UserProfile =
context.UserProfiles.Where(Function(f) f.UserId = memberId).SingleOrDefault()
' Email before the change: "a@a.com"
userProfile.UserName = "b@b.com"
context.SaveChanges()
但是,在此更新之后,HttpContext 仍将用户报告为他们的旧电子邮件。
' Name is "a@a.com" but should be "b@b.com"
HttpContext.User.Identity.Name
起初我以为我可以将用户注销并重新登录
WebSecurity.Logout()
' but I don't have the user's password
WebSecurity.Login("b@b.com", "???")
如何以某种方式刷新身份验证 cookie 以反映用户更改其登录详细信息?