Session的登录验证:

 sender, EventArgs e)
{
        if (Session.Count == 0)
        {
            Response.Write(
"超时"); //Session生存时间默认是20分钟,可以在web.config中修改
        }
        
else
        {
            
if (Session["adminName"== null)
            {   
                Response.Redirect(
"~/default.aspx")
            }
            
else 
                Response.Write(Session[
"adminName"].ToString()); 
        }
}

在登录界面用了两个TextBox控件就是tbName、tbPwd ,查看数据库有记录的用户,把输入的数据给Session。
     Session.Add ("adminName",tbName.Text);
     Session.Add("adminPwd",tbPwd.Text);

进入接收:
     Response.Write(Session["adminName"]);
     Response.Write(Session["adminPwd"]);
另外:2.0可以配置,进入IIS站点的属性--asp.net选项卡,点击“编辑配置”,进入asp.net配置设置,在“状态管理”选项卡处可以修改。或者你直接在web.config中手动修改。

相关文章:

  • 2021-12-16
  • 2021-10-29
  • 2021-11-26
  • 2022-01-29
  • 2021-12-05
  • 2021-12-05
猜你喜欢
  • 2021-12-21
  • 2022-12-23
  • 2021-09-07
  • 2021-11-25
  • 2022-12-23
相关资源
相似解决方案