我正在使用以下内容来控制用户登录身份验证。当用户处于非活动状态或被锁定时,此重定向很好,但是当用户从数据库中删除时,我收到一条错误消息......
此行上的“对象引用未设置为对象的实例”...
If currentuser IsNot Nothing And currentuser.IsApproved = False Or currentuser.IsLockedOut = True Then
什么可能导致这种情况发生?
Protected Sub Page_Init(sender As Object, e As System.EventArgs) Handles Me.Init
If User.Identity.IsAuthenticated Then
Dim currentuser As MembershipUser = Membership.GetUser()
If currentuser IsNot Nothing And currentuser.IsApproved = False Or currentuser.IsLockedOut = True Then
FormsAuthentication.SignOut()
FormsAuthentication.RedirectToLoginPage()
End If
If currentuser IsNot Nothing Then
Response.Redirect("~/media")
End If
End If
End Sub