Is it possible to count how many times a user has logged with wrong password or username

Viewed 267

I am trying to display how many times renaming to log in to the system. But I did not reach to solution for this issue.

This is the code

private void LogInUser(string username, string password)
{
  UserManager um = new UserManager();

  if (!um.ValidateUser(username, password))
  {
    um.loginCount = 5;
    lblErrorMessage.Visible = true;
    um.loginCount --;
    lblErrorMessage.Text = "TAKE CARE, Invalid username or password you have  (" + um.loginCount + ") times remaining "; // mycbLanguage.GetMessage("InvalidUsernamePswrd");
    // SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();

    return;
  }
}
1 Answers

Use int variable to count this this

//Use variable

    int i=5;

//code

    UserManager um = new UserManager();

        if (!um.ValidateUser(username, password))
        {
            i--;
            //um.loginCount = 5;
            lblErrorMessage.Visible = true;
            //um.loginCount --;
            lblErrorMessage.Text = "TAKE CARE, Invalid username or password you have  (" + i + ") times remaining "; // mycbLanguage.GetMessage("InvalidUsernamePswrd");
           // SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();

            return;

        }
Related