c# - Login control to redirect to different pages depending on the query executed -


i have 2 queries.. want if login control finds username , password in 1st query table redirect seller page.. if finds un , pw in 2nd query table redirect dealer page. how can that? coz checks first query.

 protected void login1_authenticate(object sender, authenticateeventargs e)     {         var constring = configurationmanager.connectionstrings["constring"].connectionstring;         sqlconnection con = new sqlconnection(constring);         string user = login1.username;         string pass = login1.password;         con.open();         sqlcommand cmd1 = new sqlcommand("select username, password, status login username = '" + user + "' , password = '" + pass + "' , status = 1", con);         string currentname;         currentname = (string)cmd1.executescalar();         if (currentname != null)         {              session.timeout = 1;             session["un"] = login1.username;             response.redirect("sellerlogin.aspx?un=" + login1.username);          }         sqlcommand cmd2 = new sqlcommand("select username, password, status dealer username = '" + user + "' , password = '" + pass + "' ", con);          string currentnam;         currentnam = (string)cmd2.executescalar();         if (currentnam != null)         {             session.timeout = 1;             response.redirect("dealerlogin.aspx?un="+ login1.username);         } 

try using:

response.end(); return; 

with code:

protected void login1_authenticate(object sender, authenticateeventargs e) {     var constring = configurationmanager.connectionstrings["constring"].connectionstring;     sqlconnection con = new sqlconnection(constring);     string user = login1.username;     string pass = login1.password;     con.open();     sqlcommand cmd1 = new sqlcommand("select username, password, status login username = '" + user + "' , password = '" + pass + "' , status = 1", con);     string currentname;     currentname = (string)cmd1.executescalar();     if (currentname != null)     {          session.timeout = 1;         session["un"] = login1.username;         response.redirect("sellerlogin.aspx?un=" + login1.username);         response.end();         return;     }     sqlcommand cmd2 = new sqlcommand("select username, password, status dealer username = '" + user + "' , password = '" + pass + "' ", con);      string currentnam;     currentnam = (string)cmd2.executescalar();     if (currentnam != null)     {         session.timeout = 1;         response.redirect("dealerlogin.aspx?un="+ login1.username);         response.end();         return;     } 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -