ASP.NET浏览器显示"网页已过期"为后退按钮(后一个回) [英] ASP.NET browser shows "web page has expired" for back button (after a post back)

查看:326
本文介绍了ASP.NET浏览器显示"网页已过期"为后退按钮(后一个回)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在与后回发一个简单的ASP.NET应用程序和后退按钮的麻烦。

I'm having trouble with a simple ASP.NET application and the back button after a post back.

问题的网页上有一个简单的形式,一些文本字段等,并做了回发(自动回)下拉。

The page in question has a simple form on it, some text fields etc, and a dropdown that does a postback (autopostback).

正常的流量是用户填写表单,也许改变了下拉列表。基于下拉值的页面内容可能会发生变化。

The "normal" flow is the user fills out the form and perhaps changes the dropdown. Based on the dropdown value the page content might change.

我遇到的问题是,用户改变了下拉列表,并回传完成后,然后在用户单击后退按钮。他们看到一个从IE浏览器网页已经过期的消息。

The problem I'm having is that after the user has changed the dropdown and the postback has completed then the user clicks the back button. They see a "webpage has expired" message from IE.

我已经设置了以下内容:

I've set the following:

Response.Cache.SetExpires(DateTime.Now.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.Private);

但是,这似乎并没有钉上了这个问题。

But that doesn't seem to have nailed the problem.

实际的Cache-Control响应头内容:私有,无缓存:设置Cookie

The actual Cache-Control response header reads as: private, no-cache:"Set-Cookie"

在一个传统的ASP应用程序的只有私人返回按钮的缓存控制响应头为回传之后有望行为方式。

In a classic ASP application the with a Cache-Control response header of just "private" the back button behaves as expected after a "post back".

反正是有强制ASP.NET明确设置缓存控制精确私?或者说,导致后面的按钮,任何其他解决方案回传合作得很好?

Is there anyway to force ASP.NET to set the cache-control explicitly to exactly "private"? Or any other solution that results in the back button and postbacks working well together?

谢谢!

推荐答案

根据情况可能会逃脱这个技巧/解决方法:

Depending on a situation you might get away with this hack/workaround:

 private void Page_PreRender(object sender, System.EventArgs e)
    {
        if (IsPostBack && !IsCallback)
        {

            Response.Write("<html><head><script>location.replace('" + Request.Path + "');\n" + "</script></head><body></body></html>\n");

            Response.End();

        }

    }

这篇关于ASP.NET浏览器显示&QUOT;网页已过期&QUOT;为后退按钮(后一个回)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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