marc
marc

Reputation: 23

Navigate back & reload page

I have a problem with the navigation in my ASP.NET (Framework 4) web project. I have a login field on the master-page. The master-page contains also one ContentPlaceHolder which dynamically includes other aspx pages. I start on page "a" and navigate to page "b". When I log in on page "b", an additional node in my navigation becomes visible. Now to my problem: When I push the "history-back"-button from the browser the additional node disappears on page "a".

I found out that the page "a" doesn't reload again because it's loaded from the browser's cache.

I tried something with a LinkButton (Zurueck):

protected void Page_Load(object sender, EventArgs e)
{
    Zurueck.Attributes.Add("onClick", "javascript:history.back(); return false;");
}

I also tried something with cache restrictions in the C# source and in aspx source:

protected void Page_Load(object sender, EventArgs e)
{
    Response.Cache.SetCacheability(HttpCacheability.NoCache);

    if (Session["sessionKuerzel"] != null)
    {
        view = (TreeView)this.FindControl("TreeViewVerwaltung");
        view.Visible = true;
        login = (Button)this.FindControl("Senden");
        login.Visible = false;
        logout = (Button)this.FindControl("Logout");
        logout.Visible = true;
        benutzerrecht = (string)(Session["sessionRecht"]);
        if (benutzerrecht.Equals("Administrator")){
            view.Nodes[0].ChildNodes[1].SelectAction = TreeNodeSelectAction.Select;
        }
        else{
            view.Nodes[0].ChildNodes[1].SelectAction = TreeNodeSelectAction.None;
        }
        view.Visible = true;
    }          
}

Site.Master.aspx (Head):

<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>

But all these alternatives don't work with Mozilla FireFox.

How can I navigate back in history & reload the page again? Any ideas or solutions?

Upvotes: 2

Views: 9449

Answers (1)

santosh singh
santosh singh

Reputation: 28642

try this

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Response.Buffer = true;
            Response.CacheControl = "no-cache";
            Response.AddHeader("Pragma", "no-cache");
            Response.Expires = -1441;
        }


    }

Upvotes: 5

Related Questions