c# - User based authorisation not working ASP.net -


dear senior members of stackexchange

i trying give user based authorisation urls. have configured web.config @ root below

<authentication mode="forms">   <forms       name="myauth"       loginurl="abc/login.aspx"       protection="all"       path="/"     /> </authentication> 

another web.config @ abc directory below

<?xml version="1.0"?> <configuration> <system.web>   <authorization>     <deny users="?" />   </authorization> </system.web> </configuration> 

every thing working fine except login when access directory abc login page displayed after giving correct username , password page redirected login page itself.

i new c# , asp.net

please me code @ aspx.cs below

protected void login1_authenticate(object sender, authenticateeventargs e)     {          string selectstring = "select * users " + "where username = '" + login1.username + "' , password = '" + login1.password + "'";          mysqlcommand mysqlcommand = new mysqlcommand(selectstring,con);         con.open();         string strresult = string.empty;         strresult = mysqlcommand.executescalar().tostring();         con.close();          if (strresult.length > 0)         {             e.authenticated = true;             response.redirect("up.aspx");         }          else         {             msgbox("wrong username or password!.", this.page, this);             return;         }     } 

please me thank santosh sharma

in code use following instead :

 if (strresult.length > 0)     {        formsauthentication.redirectfromloginpage           (login1.username, true);         response.redirect("up.aspx");     } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -