c# - Response.Redirect won't send me to next page -
i ran big problem here dont know in anymore. before added login system response.redirect worked charm. know login works fine ran debug on , files works fine , goes on should.
edit 1: noticed if commentate master.userlogin(arr); out default btnlogin_click , type server.transfer(@"~\admin\side.aspx"); works again dont see why making session stop response?
edit 2: okay seems has site.master.cs create session varriabler , after tries redirect page. how fix this?
default.aspx.cs
protected void btnlogin_click(object sender, eventargs e) { db.connopenhelpdesk(); if (db.helpdeskdblogin(txtbrugernavn.text, txtpassword.text).count() == 8) { if (db.helpdeskdblogin(txtbrugernavn.text, txtpassword.text)[7] == "2" || db.helpdeskdblogin(txtbrugernavn.text, txtpassword.text)[7] == "1") { master.userlogin(db.helpdeskdblogin(txtbrugernavn.text, txtpassword.text)); } } else { db.connclosehelpdesk(); lblerror.forecolor = color.red; lblerror.visible = true; lblerror.text = "dit brugernavn og password passer ikke sammen prøv igen."; } //master.userlogin(txtbrugernavn.text, txtpassword.text); }
dbcontrol.cs
public string[] helpdeskdblogin(string brugernavn, string password) { string sql = "select * admin brugernavn = '" + brugernavn + "' , password = '" + password + "'"; sqlcommand command = new sqlcommand(sql, m_helpdeskconnection); sqldatareader reader = command.executereader(); if (reader.hasrows) { while (reader.read()) { arr = new string[8] { "" + reader["id"], "" + reader["brugernavn"], "" + reader["password"], "" + reader["email"], "" + reader["telefonnr"], "" + reader["navn"], "" + reader["nytpass"], "2" }; } reader.close(); return arr; } else { reader.close(); string sql2 = "select * kunder brugernavn = '" + brugernavn + "' , password = '" + password + "'"; sqlcommand command2 = new sqlcommand(sql2, m_helpdeskconnection); sqldatareader reader2 = command2.executereader(); if (reader2.hasrows) { while (reader.read()) { arr = new string[8] { "" + reader["kundenr"], "" + reader["brugernavn"], "" + reader["password"], "" + reader["email"], "" + reader["telefonnr"], "" + reader["navn"], "" + reader["nytpass"], "1" }; } reader2.close(); return arr; } else { reader2.close(); string[] arr = new string[1]; return arr; } } }
site.master.cs
public void userlogin(string[] arr) { if (arr[7] == "1") { session["kundenr"] = arr[0]; session["brugernavn"] = arr[1]; session["email"] = arr[3]; session["telefonnr"] = arr[4]; session["kundenavn"] = arr[5]; session["nytpass"] = arr[6]; session["rang"] = arr[7]; response.redirect(@"~\bruger\side.aspx"); } else if (arr[7] == "2") { session["kundenr"] = arr[0]; session["brugernavn"] = arr[1]; session["email"] = arr[3]; session["telefonnr"] = arr[4]; session["kundenavn"] = arr[5]; session["nytpass"] = arr[6]; session["rang"] = arr[7]; response.redirect(@"~\admin\side.aspx"); } }
you not setting authentication cookies. result, user redirected login screen since not have rights view internal pages of website.
Comments
Post a Comment