We help IT Professionals succeed at work.
Get Started

cannot login from firefox- asp.net login functionality

640 Views
Last Modified: 2012-05-06
This is so freaking strange,

When I try to login using Firefox, I get a default error message (which I have set in the _LoginError sub)

the thing is the when I login using a particular username(in my case 'test'), i can login from IE but not firefox

All other logins work fine in both browsers

have tried rebooting the PC, clearing cookies, removing temp asp.net files.

following is the code, i use this code to use the remember me funcitonality

p.s. safari for windows doesnt throw this problem, only Firefox
Private Sub portalLogin_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles portalLogin.Init
        If Not IsPostBack Then
            If Request.Cookies("myCookie") IsNot Nothing Then
                Dim cookie As HttpCookie = Request.Cookies.[Get]("myCookie")
                portalLogin.UserName = cookie.Values("username")
 
                portalLogin.RememberMeSet = (Not [String].IsNullOrEmpty(portalLogin.UserName))
            End If
            Dim txtUser As TextBox = TryCast(portalLogin.FindControl("UserName"), TextBox)
            If txtUser IsNot Nothing Then
                'Me.SetFocus(txtUser)
            End If
        End If
 
        ' Note this
        Response.Cache.SetNoStore()
 
    End Sub
 
    'redirect the user to the HOME page when he logs in
    Private Sub portalLogin_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles portalLogin.LoggedIn
        'get user name
        Dim usern As String = portalLogin.UserName.ToString
 
        Dim myCookie As New HttpCookie("myCookie")
        Dim remember As Boolean = portalLogin.RememberMeSet
 
        If remember Then
            Dim persistDays As Int32 = 60 'cookie set toe expire in 60 days
            myCookie.Values.Add("username", portalLogin.UserName)
            myCookie.Expires = DateTime.Now.AddDays(persistDays)
            'you can add years and months too here
        Else
            myCookie.Values.Add("username", String.Empty)
            ' overwrite empty string is safest
            myCookie.Expires = DateTime.Now.AddMinutes(5)
            'you can add years and months too here
        End If
 
        Response.Cookies.Add(myCookie)
 
        
        
    End Sub
 
 
    Protected Sub portalLogin_LoginError(ByVal sender As Object, ByVal e As System.EventArgs) Handles portalLogin.LoginError
        'determine why the user could not login...
        portalLogin.FailureText = "Your login attempt was not sucessful. Please try again"
 
        'does that user account Exist ?
        Dim usrInfo As MembershipUser = Membership.GetUser(portalLogin.UserName)
 
 
        If usrInfo IsNot Nothing Then
            'is this user Locked out?
            If usrInfo.IsLockedOut Then
                portalLogin.FailureText = "Your account has been locked out because of too many invalid login attempts. Please contact administrator to re-activate it"
 
                'has user been Approved yet?
            ElseIf Not usrInfo.IsApproved Then
                portalLogin.FailureText = "Your account has not been approved yet. You cannot login until an administrator has approved your account"
            End If
 
        End If
    End Sub

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE