多撸 多幻

多撸 多幻

  • 1.9k
  • 4
  • 247

Redirect based on category

Nov 20 2017 1:17 AM
Hi guys, im doing a login page that will redirect users to a specific page based on their category. So far i can just only complete the normal login. It failed to run when i try to redirect users based on their category. My code are as below:

 

protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
   {
         SqlConnection con = new          SqlConnection(ConfigurationManager.ConnectionStrings["LoginConStr"].ConnectionString);
         con.Open();
         SqlCommand cmd = new SqlCommand("select * from Users where Username =@username          and Password=@password and Category=@category", con);
         cmd.Parameters.AddWithValue("@username", Login1.UserName);
         cmd.Parameters.AddWithValue("@password", Login1.Password);
         SqlDataAdapter da = new SqlDataAdapter(cmd);
         DataTable dt = new DataTable();
         da.Fill(dt);
               if (dt.Rows.Count > 0)
                     {            
                           if ("@category".Equals("Artist"))
                                 {
                                       Response.Redirect("Artist.aspx");
                                  }
                           else if ("@category".Equals("Buyer"))
                                 {
                                       Response.Redirect("Customer.aspx");
                                 }
                     }
}
Can you guys tell me where is my error and how should i modify it?
P.S: Sorry i can only copy my code since i dont know how to paste the code in lines like the others do.

Answers (1)