Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to redirect the error page when user clicks the back button and refresh button.

I find the solution but it is not working.

Here is my solution:


C#
Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
        Response.Cache.SetNoStore();
        Response.AppendHeader("Pragma", "no-cache");

        if (Page.IsPostBack)
        {
            if (isPageExpired())
            {
                Response.Redirect("expired.htm");
            }
            else
            {
                Session["TimeStamp"] = DateTime.Now.ToString();
                ViewState["TimeStamp"] = DateTime.Now.ToString();
            }
        }
 private Boolean isPageExpired()
    {
        if (Session["TimeStamp"] == null ||
           ViewState["TimeStamp"] == null)
            return false;
        else if (Session["TimeStamp"] == ViewState["TimeStamp"])
            return true;
        else
            return false;
    }

and

Java
javascript: window.history.forward(1);



Help me.
Posted
Updated 8-Dec-11 0:54am
v4
Comments
Dalek Dave 8-Dec-11 4:28am    
Edited for Grammar and Syntax.
thatraja 8-Dec-11 4:33am    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900