Friday, 2 September 2011

Prevent the Back option after Log Out:

Step 1 In the Page_Load event of your master page: 
protected void Page_Load(object sender, EventArgs e)
 {
   if(!IsPostBack)
   {
    if (Session["LoginId"] == null)
      Response.Redirect("frmLogin.aspx");
    else
    {
      Response.ClearHeaders();
      Response.AddHeader("Cache-Control", "no-cache, no-store,
      max-age=0, must-revalidate");
      Response.AddHeader("Pragma", "no-cache");
    }
  }
}
 
Step 2 Do clear the session on the Logout button as:
Session.Abandon();
 Session.Clear(); 
 
Step 3 
<script language="text/javascript">
function back()
{
 windows.history.forward(1);
}
</script>
<body onload="back()">
 

No comments:

Post a Comment