If you wan to authenticate any user then first you have to check that given Username and password is correct or not.
you can do this by using this code-
protected
void btnLogin_Click(object sender, EventArgs e)
{
if
(TxtUserName.Text != "" && TxtPassword.Text != "")
{
SqlConnection con =
new SqlConnection("con string");
SqlDataAdapter da;
string
mySQL = "SELECT * FROM logintable where username='" + TxtUserName.Text + "' and password='" + TxtPassword.Text + "'";
da = new SqlDataAdapter(mySQL, con);
con.Open();
DataSet ds =
new DataSet();
da.Fill(ds);
if
(ds.Tables[0].Rows.Count > 0)
{
Response.Redirect(
"home.aspx");
}
else
{
Response.Write(
"<script>alert('Invalid Username or Password.')</script>");
}
}
USE THIS CODE AND LET ME KNOW.