现在有一个登陆页面和一个登陆后的管理系统,如何才能实现下面的这种功能呢:   
     1.从登陆页面登陆后系统后,在操作页面点击“退出”按钮后回到登陆页面,此时不希望从登陆页面点击浏览器的后退按钮再回到系统?   
      2.进入系统后,在没有点击退出按钮前,在其他页面之间可以点击后退和前进按钮实现页面间切换。
我根据其它人问得情况大概是这样写代码:在Page_Load检测session,在退出按钮的ExitB_Click中清空session,可是浏览器的后退按钮根本不会引起Page_Load(),它只是根据记忆再现页面??
 protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write(Session["UserName"]);
        if (Session["UserName"] == null)
        {
            Response.Write("<script language=\"Javascript\">alert(\"注意!\")</script>");
            Response.Redirect("Login.aspx");
        }
        else
        {
            Label1.Text = Session["UserName"] + "您好!";
        }
    }
    protected void ExitB_Click(object sender, EventArgs e)
    {
        Session.Remove("UserName");
        //Session.Abandon();
        Response.Redirect("Login.aspx");
    }
   

解决方案 »

  1.   

    protected void ExitB_Click(object sender, EventArgs e) 
        { 
            //.....
            //清空所有的Session
            Session.Abandon(); 
            System.Web.Security.FormsAuthentication.SignOut();//注销form验证
            Response.Redirect("Login.aspx"); 
        } 
      

  2.   

    I'm so sorry
    我不太懂Form认证
    请问我要怎样设置这一整套?
    我想可能有点麻烦,只能以加分相谢了,谢谢?我在Web.confilg里加了:
    <authentication mode="Forms"/>
        <authorization>
          <allow users="*"/>
        </authorization>
    Logon.aspx.cs里加了:
     System.Web.Security.FormsAuthentication.RedirectFromLoginPage(UserName_TB.Text , LogCh_CB.Checked);
    这样可以吗?
      

  3.   

     LogCh_CB是一个CheckBox控件。