因此,在没有更好的方法的情况下,看起来这将为异步函数提供帮助。
/管理/禁用事实验证
. 注意
IsPersistent=真
移除cookie
IsPersistent=假
只需设置过期日期。
' POST: /Manage/DisableTwoFactorAuthentication
<HttpPost>
<ValidateAntiForgeryToken>
Public Async Function DisableTwoFactorAuthentication() As Task(Of ActionResult)
Await UserManager.SetTwoFactorEnabledAsync(User.Identity.GetUserId(), False)
Dim userInfo = Await UserManager.FindByIdAsync(User.Identity.GetUserId())
If userInfo IsNot Nothing Then
Await SignInManager.SignInAsync(userInfo, isPersistent:=False, rememberBrowser:=False)
Dim rememberBrowserIdentity = AuthenticationManager.CreateTwoFactorRememberBrowserIdentity(userInfo.Id)
AuthenticationManager.SignIn(New AuthenticationProperties With {
.IsPersistent = True, 'False still leaves old cookie but with expired date
.ExpiresUtc = Date.UtcNow.AddDays(-1)
}, rememberBrowserIdentity)
End If
Return RedirectToAction("Index", "Manage")
End Function
希望这能帮助别人!-)