Click here to Skip to main content
15,905,563 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
HTML
Session["CustomerLogin"] = "CustomerLogin";
Session["CustomerLogin"] = txtUsername.Text;
if(Session["txtRoles"] == "Cust")
Response.Redirect("~/home.aspx");
else if(Session["txtRoles"] == "Admin")
Response.Redirect("~/homeAdmin.aspx");




-------
this code is under LogIn button. I want it to allow a User to Log In to a page according to his/her details.

no error is shown but when i am trying to log in it doesn't allow the user to.
Whats The Problam?
Posted
Updated 29-Jun-13 6:53am
v2
Comments
ridoy 29-Jun-13 12:54pm    
clear your question more..

C#
if(Session["Name1"]=="value1")
  {

    Response.Redirect("Page1.aspx");
  }

  else if(Session["Name2"]=="Value2")
   {

    Response.Redirect("Page1.aspx");

   }
 
Share this answer
 
protected void btnLogin_Click(object sender, EventArgs e)
{

try
{
if (check())
{
Sessio[CustomerLogin] = CustomerLogin;
Session[CustomerLoginName] = txtUsername.Text;
if (Session[txtRoles] == Cust)
{
Response.Redirect(~home.aspx);
}
else if (Session[txtRoles] == Admin)
{
Response.Redirect(~categories.aspx);

}
}
else
{
errorDV.Visible = true;
txtUsername.Focus();
}
if (txtUsername.Text.Length == 0 txtPassword.Text.Length == 0)
{

errorDV.Visible = true;
txtUsername.Focus();
}
}
catch
{
errorDV.Visible = true;
txtUsername.Focus();
}

}
private bool check()
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
SqlCommand com = new SqlCommand(select count() from Customer where Username = @uname ,Password = @upass and Roles = @urole, con);
com.Parameters.Add(@uname, SqlDbType.VarChar).Value = txtUsername.Text;
com.Parameters.Add(@upass, SqlDbType.VarChar).Value = MD6Result(txtPassword.Text);
com.Parameters.Add(@urole, SqlDbType.VarChar).Value = txtRoles.Text;
if (com.ExecuteScalar().ToString() == 1)
return true;
con.Close();
return false;
}

private string MD6Result(string input)
{
string str = MD5Result(input) + SmartAccessoriesInc;
return MD5Result(str);
}
private string MD5Result(string input)
{
MD5 x = new MD5CryptoServiceProvider();
byte[] lam = Encoding.UTF8.GetBytes(input);
lam = x.ComputeHash(lam);
StringBuilder s = new StringBuilder();
foreach (byte b in lam)
{
s.Append(b.ToString(x2).ToLower());
}
return s.ToString();
}
---------------------
This is the rest of the Code.
Please help out
 
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