我有一个使用 ASP.net 的网站...我使用从 Visual Web Developer 访问的 ASP.net 网站管理工具来添加/修改用户对该网站的访问权限。我注意到,如果用户选中了“记住我”框以自动登录,那么在删除 cookie 之前禁用或删除该帐户将无效。为什么是这样?是否可以在代码中添加某种类型的逻辑来拒绝访问或将它们重定向到禁用或删除帐户的错误消息?
这就是我目前在我的代码后面的内容......
Protected Sub Page_Init(sender As Object, e As System.EventArgs) Handles Me.Init
If User.Identity.IsAuthenticated Then
Response.Redirect("~/homepage")
End If
End Sub
这也在 Page_Init 部分的下方......
Protected Sub LoginUser_LoginError(sender As Object, e As System.EventArgs) Handles LoginUser.LoginError
LoginUser.FailureText = "Invalid Username or Password - Please Try Again"
Dim usrInfo As MembershipUser = Membership.GetUser(LoginUser.UserName)
If usrInfo IsNot Nothing Then
If usrInfo.IsLockedOut Then
LoginUser.FailureText = "Your account has been locked - Contact the system administrator"
ElseIf Not usrInfo.IsApproved Then
LoginUser.FailureText = "Your account is disabled - Contact the system administrator"
End If
End If
End Sub
谢谢您的帮助!