Thursday 6 June 2013

Stopping Previous Page navigation after log out in ASP.NET C#

After Signout click on back button is goto previous page  ,solution is copy below code in  page_load event

if  your using Master page  then same code copy in masterpage page_load event



 Codebehind:

 protected void Page_Load(object sender, EventArgs e)
    {
        if ( Session["user"]==null)
        {
            Response.Redirect("../admin/login.aspx");
        }
        
        Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        HttpContext.Current.Response.Cache.SetNoStore();
}



  protected void   Logout_Click (object sender, LoginCancelEventArgs e)
    {
        Session["user"] = null;
        Session.Abandon();
        Response.Redirect("../admin/login.aspx");
     }

No comments:

Post a Comment