我这里已经判断Session了,可是我在地址栏输入网址,为什么还能直接进去呢
protected void Page_Load(object sender, EventArgs e)
{
if (Session["userId"] != null)
{
DataSet ds = new DataSet();
db.RunSQL("select userName from Users where userId='" + Session["userId"] + "'", ref ds, "Users");
userName.Text = ds.Tables["Users"].Rows[0][0].ToString();
}
else
{
Response.Redirect("~/back/login.aspx");
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Session.Remove("userId");
Session.RemoveAll();
Response.Redirect("~/back/login.aspx");
}