Click here to Skip to main content
15,922,574 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to stop Bypass Login from asp.net login page. I have used sql server 2005 and .net framework 3.5, and using C# language. I have checked login id and password from database.If lofin id and password is correct then user can logged in and can use the application. But my question is that,when my friend entered anything login id in login field and entered something in password field, and he successfully logges in and can use the application.Later I knew that its a bypass login.I want to stop the bypass login. Anyone can help me please....

[Edit: Shouting Removed]
Posted
Updated 19-May-13 20:09pm
v2

You can check database at login time for provided username and password existance.If it doesnt find the one,revoke the access.

C#
SqlConnection conn = new SqlConnection();
conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["your connection string name"].ConnectionString;
conn.Open();
SqlCommand cmd = new SqlCommand("Select uname, pswd from table where uname = @id and pswd = @password ", conn);
cmd.Parameters.Add(new SqlParameter("@id", "id here"));
cmd.Parameters.Add(new SqlParameter("@password", "password here"));
SqlDataReader dr = cmd.ExecuteReader();
if(dr.Read())
{
     //Username and password found.User exists.
}
else
{
        //Username or password not found.Throw error message.
        Response.Write("<script type='text/javascript'>");
        Response.Write("alert('Invalid Credentials.');");            
        Response.Write("</script>");
}
 
Share this answer
 
v2
Comments
Sunasara Imdadhusen 20-May-13 8:32am    
Good explanation...I recommend your solution as well!!!
Thanks7872 20-May-13 11:43am    
Sorry,it was wrongly commented by me.Thanks alot for this appreciation.
This is not possible to bypass your authentication process. instead of you have to provide proper security like

1. Client and server side validation - to restrict invalid data entry
2. Prevent HTML, SQL injection
3. Database call check - verify user's information (id and password?) with your database value and then allow access to your application if requested user's id and password is match with DB.
4. Apply encryption - Store user id and password in encrypted format so no one can break security.

Thanks
 
Share this answer
 

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