gpt4 book ai didi

c# - asp.net c# 中的登录页面错误

转载 作者:太空宇宙 更新时间:2023-11-03 17:01:03 25 4
gpt4 key购买 nike

我有一个登录页面,我在其中编写了用于登录管理部分的代码,但它无法正常工作我不知道这是什么问题,代码是正确的,但仍然存在未经授权的访问。帮帮我

  string str = ConfigurationManager.ConnectionStrings["ottscon"].ConnectionString;
using (SqlConnection con = new SqlConnection(str))
{
SqlCommand cmd = new SqlCommand("Select UserName,Password from login where UserName=@userid and Password=@passid", 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;
}
}

最佳答案

您没有正确传递值

TextBox1.ToString() 错误

使用

TextBox1.Text

关于c# - asp.net c# 中的登录页面错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32242983/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com