0
从表单验证远离,并尝试能够成功让我的索赔周围用户的身份登录头使用此MVC登出声明身份验证
Dim vIdentity As New ClaimsIdentity({New Claim(ClaimTypes.Name, Session("UserName"))}, DefaultAuthenticationTypes.ApplicationCookie, ClaimTypes.Name, ClaimTypes.Role)
vIdentity.AddClaim(New Claim(ClaimTypes.Role, "User"))
Authentication.SignIn(New AuthenticationProperties With {.IsPersistent = False}, vIdentity)
但与注销的问题 - 我想AuthenticationManager.Signout( )会工作,但我得到'退出不是AuthenticationManager的成员',所以现在有点难倒了。
这是全球
System.Web.Helpers.AntiForgeryConfig.UniqueClaimTypeIdentifier = System.Security.Claims.ClaimTypes.Name
我想这在注销控制器
Function Index() As ActionResult
If User.Identity.IsAuthenticated Then
Dim vUser = TryCast(User, ClaimsPrincipal)
Dim vIdentity = TryCast(User.Identity, ClaimsIdentity)
Dim vClaim = (From c In vUser.Claims Where c.Value = Session("UserName") Select c).Single()
vIdentity.RemoveClaim(vClaim)
End If
Return View()
End Function
但返回错误
A claim of type 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name' was not present on the provided ClaimsIdentity.
当它击中
@Html.AntiForgeryToken()
有什么想法?
感谢