locked
handle connection fail RRS feed

  • Question

  • User32875325 posted

    Hi all,

    I had a login control which is link to the MembershipProvider. During the validating of user, it will connect to the database.

    If the connection is unsuccessful, I would like to pop up a message box "Connection Unsuccessful" once I click on Login.

    May I know how to do that?

    Thanks

    Wednesday, May 14, 2008 4:56 AM

Answers

  • User-186742165 posted

    Hi

    The best practice is handle the exception in a try catch block when validating user information.

        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            try{
                Membership.ValidateUser("userName", "password");
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
      
        }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 16, 2008 4:02 AM

All replies

  • User-1581724896 posted

    If the connection is unsuccessful, I would like to pop up a message box "Connection Unsuccessful" once I click on Login.

    Is it that you mean to say that the login is unsuccessful when the user provides a wrong username/password? 

    Wednesday, May 14, 2008 5:46 AM
  • User32875325 posted
    no, I am actually referring to connection fail due to server or database down.
    Wednesday, May 14, 2008 9:35 PM
  • User-186742165 posted

    Hi

    The best practice is handle the exception in a try catch block when validating user information.

        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            try{
                Membership.ValidateUser("userName", "password");
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
      
        }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 16, 2008 4:02 AM