Login.aspx.vb Code not functioning

Results 1 to 2 of 2

Thread: Login.aspx.vb Code not functioning

  1. #1
    Join Date
    Jan 2013
    Posts
    4

    Default Login.aspx.vb Code not functioning

    Hi everyone,

    My Login.aspx.vb page code is following. But When I enter wrong password then Redirect it to ("~/expirationmessage.aspx"), at the same time when I enter right password then it goes to default page.

    ****On the Other hand Response.Redirect("~/idlock.aspx") is not work though I enter wrong password above 5 times.

    **** Another problem is when I try to login a user who already expired but can easily enter.

    I m using Access Database. Please Help to solve the problem.

    Protected Sub Login1_LoginError(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoginError


    'There was a problem logging in the user
    'See if this user exists in the database
    Dim userInfo As MembershipUser = Membership.GetUser(Login1.UserName)
    Dim RenewDate = Profile.GetProfile(Login1.UserName).DateRenewed
    If userInfo Is Nothing Then
    'The user entered an invalid username...
    Response.Redirect("~/invaliduser.aspx")
    Else
    'The password was incorrect (don't show anything, the Login control already describes the problem)

    End If

    'See if the user is not approved
    If Not userInfo.IsApproved Then
    Response.Redirect("~/approval.aspx")
    'See if the user is locked out
    ElseIf userInfo.IsLockedOut Then
    Response.Redirect("~/idlock.aspx")
    'Expiration of User
    ElseIf DateDiff(DateInterval.Day, RenewDate, DateTime.Now) > 365 Then
    Response.Redirect("~/expirationmessage.aspx")


    End If

    End Sub

  2. #2
    Join Date
    Sep 2008
    Posts
    467

    Default

    Debug, debug, debug.

    Let's deal with one problem at at time. First, the lock out problem. Is IsLockedOut set to true? When you enter an incorrect password, is FailedPasswordAttempCount correctly incremented in the database? Is FailedPasswordAttemptWindowStart correctly set to the current date/time? What are your settings for locking out an account in web.config?

    Then, if all that data looks to be correct, and you even getting to that point in the code, or is the function exiting early even when the user is locked out?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •