因此,我使用Response.Redirect控件移动到名为“ Equipment.aspx”的页面,它工作正常,但过了一会儿它开始被重定向到页面“ OpeningPage.aspx”。
我尝试再次创建这些页面,并将页面名称从“ OpeningPage.aspx”更改为“ Opening_Page.aspx”,当我尝试运行该页面时,显示未找到http:404文件错误和RequestedURL:/OpeningPage.aspx < / p>
SqlConnection sqlcon = new SqlConnection(con);
sqlcon.Open();
string checkuser = "SELECT count(*) FROM UserAccounts WHERE UserName = '" + username.Text + "'";
SqlCommand cmd = new SqlCommand(checkuser, sqlcon);
int temp = Convert.ToInt32(cmd.ExecuteScalar().ToString());
sqlcon.Close();
if (temp == 1)
{
sqlcon.Open();
string checkpassword = "SELECT Password FROM UserAccounts WHERE UserName = '" + username.Text + "'";
SqlCommand cmdt = new SqlCommand(checkpassword, sqlcon);
string tem = cmdt.ExecuteScalar().ToString();
if (tem == password.Text)
{
Session["usersession"] = username.Text;
Response.Redirect("Equipment.aspx");
}
else
{
Response.Write("incorrect password");
}
}
else
{
Response.Write("incorrect username");
}
以下是“ Equipment.aspx.cs”页面的代码:
protected void Page_Load(object sender, EventArgs e)
{
if(Session["usersession"] != null )
{
usernam.Text = Session["usersession"].ToString();
}
else
{
Response.Redirect("Login.aspx");
}
}
protected void logout_Click(object sender, EventArgs e)
{
Session.RemoveAll();
Response.Redirect("~/Opening_Page.aspx");
}