I am using the following to control user log in authentication. This redirects fine when the user is inactive or locked out, but when the user is deleted from the database, I get an error message...
"Object reference not set to an instance of an object" on this line...
If currentuser IsNot Nothing And currentuser.IsApproved = False Or currentuser.IsLockedOut = True Then
What could be causing this to happen?
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