简体   繁体   English

导航返回并重新加载页面

[英]Navigate back & reload page

I have a problem with the navigation in my ASP.NET (Framework 4) web project.我的 ASP.NET(框架 4)web 项目中的导航有问题。 I have a login field on the master-page.我在母版页上有一个登录字段。 The master-page contains also one ContentPlaceHolder which dynamically includes other aspx pages.母版页还包含一个动态包含其他 aspx 页面的 ContentPlaceHolder。 I start on page "a" and navigate to page "b".我从“a”页开始并导航到“b”页。 When I log in on page "b", an additional node in my navigation becomes visible.当我在页面“b”上登录时,我的导航中的一个附加节点变得可见。 Now to my problem: When I push the "history-back"-button from the browser the additional node disappears on page "a".现在我的问题是:当我从浏览器中按下“历史记录”按钮时,附加节点会在“a”页面上消失。

I found out that the page "a" doesn't reload again because it's loaded from the browser's cache.我发现页面“a”不会再次重新加载,因为它是从浏览器的缓存中加载的。

I tried something with a LinkButton (Zurueck):我用 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:我还在 C# 源和 aspx 源中尝试了一些缓存限制:

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): Site.Master.aspx(头):

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

But all these alternatives don't work with Mozilla FireFox.但是所有这些替代方案都不适用于 Mozilla FireFox。

How can I navigate back in history & reload the page again?如何返回历史记录并重新加载页面? Any ideas or solutions?有什么想法或解决方案吗?

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;
        }


    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM