Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
how to terminate login page in asp.net using c# for 3 wrong password
Posted
Comments
BobJanova 16-Feb-12 7:48am    
Are you using the default Membership/Role stuff, or are you using a completely custom authentication scheme?
thatraja 16-Feb-12 8:04am    
Good call, you may post that as an answer with some more details.
BobJanova 16-Feb-12 9:50am    
It's two completely different answers depending on which way he's doing authentication, and I don't feel like writing both :P (actually doing work at work today).
thatraja 16-Feb-12 10:11am    
:D

there is no direct way of doing this
you have to do workaround

1)Create one table in database with field as Blockloginpage (boolean datatype)
2)Insert 0 in this table
3)then update this table for 1 if three atempt of wrong password found
4)check the value in this table if this is 1 then do display other page with proper msg.

If this helps then accept and vote the answer
--Rahul D.
 
Share this answer
 
Hi Suresh,

you can try this

C#
static int intCounter = 0;
           intCounter = intCounter + 1;

            textBox1.Text = "";
            textBox2.Text = "";
            textBox2.Text = "*";

            if ((intCounter < 3))
            {
                if ((textBox2.Text == "password" && textBox2.Text == "User"))
                {
                    MessageBox.Show("User name and password are correct");
                }
                else
                {
                    str = Convert.ToString(3 - intCounter);
                    MessageBox.Show("User name or password incorrect! You have " + str + " tries left.");
                }
            }
            else
            {
                MessageBox.Show("User name or password incorrect! You have no attempts remaining and the system is locked.");
                Application.Exit();
            }
 
Share this answer
 
Comments
Dylan Morley 16-Feb-12 8:02am    
Does not apply to Asp.Net

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900