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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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;
}
}
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0