c# - How to implement different user login with login control in asp.net VS2015 -
good morning everybody, have meet trouble in implementing different user login login control in asp.net, have tried lots of time , search long long time, failed.
can me? lot :).
here code,
when input correct username adn psw, redirect default.aspx though never let redirect default.aspx @ all. when delete default.aspx has error :( i'm cry :(
protected static boolean authentication(string username, string password) { string sql = "select studentid student studentid='" + username + "' , psw= '" + password + "'"; string consqlserver = "server=localhost;user=sa;pwd=6616;database=ustcsse"; system.data.sqlclient.sqlconnection con = new system.data.sqlclient.sqlconnection(consqlserver); system.data.sqlclient.sqlcommand comm = new system.data.sqlclient.sqlcommand(sql, con); system.data.sqlclient.sqldatareader reader; con.open(); reader = comm.executereader(); if (reader.read()) return true; else return false; } protected void login1_authenticate1(object sender, authenticateeventargs e) { boolean blnresult; blnresult = false; blnresult = authentication(login1.username, login1.password); if (blnresult == true) { e.authenticated = true; if(login1.username=="admin") response.redirect("~/admin.aspx", false); else response.redirect("~/welcome.aspx", false); } else e.authenticated = false; } and here web.config:
<authentication mode="forms"> <forms loginurl="login.aspx" name=".aspxformsauth" > </forms> </authentication> <authorization> <deny users="?"/> </authorization>
Comments
Post a Comment