Click here to Skip to main content
15,917,862 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i am using code for authentication in my web.config.when i write the code for authentication and run the project and give my username and password it does not go to the next page... please help me
this is my code for authentication...
XML
<authentication mode="Forms">
      &lt;<forms name="Mysite" loginUrl="~/Login.aspx" protection="All" timeout="30" path="/" requireSSL="false" slidingExpiration="true" cookieless="UseCookies" />

        </authentication>
    <authorization>
      <deny users="?"/>
    </authorization>
Posted
Updated 29-May-13 21:24pm
v2
Comments
Zoltán Zörgő 30-May-13 3:24am    
Depends on the Login.aspx. What's in it?
fak_farrukh 30-May-13 3:28am    
login.aspx page

protected void Button1_Click(object sender, EventArgs e)
{
try
{
// string username = txtusername.Text;
// string pwd = txtpassword.Text;

SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Administrator\Desktop\Orignal Project Part 1\Inventory Management System\IMS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
string query = "SELECT [user].* FROM [user] where u_name='" + txtusername.Text + "' and pwd='" + txtpassword.Text + "'";
SqlCommand com = new SqlCommand(query, con);
con.Open();


// Session["username"] = txtusername.Text;


if (txtusername.Text == "admin")
{

if (com.ExecuteReader().HasRows)
{



Response.Redirect("index.html");
Label3.Text = "successfully";



}
else
{
Label3.Text = "not successfully";
txtusername.Text = "";
txtpassword.Text = "";
}
}
else if (txtusername.Text == "user")
{
if (com.ExecuteReader().HasRows)
{


Response.Redirect("userinventory.aspx");
Label3.Text = "successfully";



}
else
{
Label3.Text = "not successfully";
txtusername.Text = "";
txtpassword.Text = "";
}
}

con.Close();
}
catch (Exception ex)
{
Console.Write("" + ex.Message);
}

1 solution

Refer to below link

How to: Implement Simple Forms Authentication[^]

Furhter,verify all your URLs,path according to folders.Debug your login page to check whats going on.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900