后退按钮刷新页面 [英] Back button refresh page

查看:159
本文介绍了后退按钮刷新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有在这里发表一些类似的问题,但没有真正满足我的需求。

There are a few similar questions posted here but none that really addresses my needs.

我有一个页面上的项目列表,让我们把它叫做masterlist.aspx。如果我在一个点击出现另一个页面,这些列表项,即details.aspx?ID =东西。

I have a list of items on one page, lets call it masterlist.aspx. If I click on one these list items another page appears, i.e. details.aspx?id=something.

在出现的页面在编辑模式FormView控件。如果用户希望编辑他们打一个编辑LinkBut​​ton的,并且形式发送到编辑模式下的数据,他们然后编辑该数据并单击保存按钮,保存数据,并把FormView控件。查看模式。

The page that appears has a formview control in edit mode. If the user wants to edit the data they hit an edit linkbutton and, the form is sent into edit mode, they then edit the data and click the save button, saving the data and putting the formview back in view mode.

问题是,如果用户使用浏览器的后退按钮返回到masterlist.aspx网页不更新网页,它退出了浏览器的缓存。

The issue is if the user uses the browser back button to go back to the masterlist.aspx page the page is not updated, it's pulled out of the browser cache.

我曾与HTTP头缓存设置发挥各地,但不能得到任何东西,在所有主要浏览器上运行。在某些浏览器,我得到的网页过期警告。另一种选择是莫名其妙地触发页面刷新(或部分页面刷新)在使用客户端code在页​​面加载,但我一直无法弄清楚如何做到这一点。

I have played around with the HTTP headers cache settings but can't get anything that works on all major browsers. On some browsers I get web page expired warnings. Another option is to somehow trigger a page refresh (or partial page refresh) when the page loads using client side code, but I haven't been able to figure out how to do this.

有没有其他的方法或有没有人已经成功与上面的两种方法,或者是有回避这个问题彻底的办法。

Is there any other approach or has anyone been successful with the two approaches above, or is there some way of avoiding the issue completely.

推荐答案

我必须做这样的事情在一个目录中,其中需要从数据库加载的每个负载,因为当你点击一个产品页面调用浏览网页到第三方获得更新的信息,然后保存它,如果它应该更新。这是这样,当你打后退按钮就像你说的数据加载。我做了什么被添加到这一点的页面,似乎在所有浏览器很好地工作。

I have to do something like this in a catalog where the browse page needs to be loaded from the DB on every load because when you hit a product page it calls out to a 3rd party to get updated info, and then save it if it should be updated. This is so when you hit the back button like you're saying the data is reloaded. What I've done is added this into the page and it seems to work fine in all browsers.

public class ProductBrowser : Page
{
    protected override void OnInit(EventArgs e)
    {
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.Cache.SetNoStore();
        Response.Cache.SetExpires(DateTime.MinValue);

        base.OnInit(e);
    }
}

这篇关于后退按钮刷新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆