我有一个登录页面,其中我已经编写代码来登录管理部分,但它不工作我不知道什么问题是这个代码是正确的仍然未经授权的访问。帮我出登录页面错误在asp.net c#
string str = ConfigurationManager.ConnectionStrings["ottscon"].ConnectionString;
using (SqlConnection con = new SqlConnection(str))
{
SqlCommand cmd = new SqlCommand("Select UserName,Password from login where [email protected] and [email protected]", con);
con.Open();
cmd.Parameters.AddWithValue("@userid", TextBox1.ToString());
cmd.Parameters.AddWithValue("@passid", TextBox2.ToString());
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds= new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count>0)
{
Session["login"] = TextBox1.Text;
Response.Redirect("admintrator123/Default.aspx");
}
else
{
Label1.Text = "Unauthorized Access";
Label1.ForeColor = System.Drawing.Color.Red;
}
}
你存储密码以纯文本形式? – Kamo
是作为纯文本 – shashank
这有点危险,你应该考虑以散列的形式存储它们。当你直接在数据库上执行查询时,你得到的参数会得到任何结果? – Kamo