We have implemented a popup window as a modal dialog using the IE method:
我们使用IE方法将弹出窗口实现为模式对话框:
window.showModalDialog('...aspx')
The target of the popup window is itself an ASP.Net web page.
弹出窗口的目标本身就是一个ASP.Net网页。
Assume for the following steps that the popup has never been launched:
假设以下步骤从未启动过弹出窗口:
- Launch popup.
- Page_Load event handler executes on server side.
- Close popup.
- Immediately launch popup again.
- This time Page_Load event handler doesn't execute.
Page_Load事件处理程序在服务器端执行。
立即再次启动弹出窗口。
这次Page_Load事件处理程序不执行。
It's clear that the popup content is being cached because if at Step 4 we clear the temporary internet files the Page_Load event handler is executed the second time.
很明显,弹出内容正在被缓存,因为如果在步骤4我们清除临时Internet文件,则第二次执行Page_Load事件处理程序。
We have experimented with adding the following to the Head of the web page (as recommended by several other sources) but none of it seems to work.
我们已经尝试将以下内容添加到网页的主管中(正如其他几个来源所推荐的那样),但它们似乎都没有效果。
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
We have also seen places where the use of these is discouraged
我们也看到了不鼓励使用这些物品的地方
Can anyone help?
有人可以帮忙吗?
9 个解决方案
#1
9
Add a timestamp querystring variable to the URL of the dialog content - number of ticks since 1/1/08 or something - IE will treat it as a new page and ignore the cache.
将时间戳查询字符串变量添加到对话框内容的URL中 - 自1/1/08以来的刻度数或其他内容 - IE将其视为新页面并忽略缓存。
#2
8
To clear cache add this in page load:
要清除缓存,请在页面加载中添加:
Response.Cache.SetCacheability(HttpCacheability.NoCache);
#3
4
Given that the http-equiv directives don’t work (and arguably shouldn’t be used), and despite it unfortunately being in the hack category of solutions, I think we are going to have to go with this (posted by Greg)...
鉴于http-equiv指令不起作用(并且可以说不应该使用),尽管不幸的是它属于黑客类别的解决方案,但我认为我们将不得不采用这种方式(由Greg发布)。 ..
url = "<Some url with query string>"
var date = new Date();
window.showModalDialog(url + “&” + date.getTime(), ... );
It is strange that there is no definitive way to disable caching on these modal dialogs. I’m not sure whether using modal dialogs in web browsers is accepted as a "good idea" or not, but we are aware of at least some of the shortcomings and alternatives, but are just unfortunately unable to use them in this project.
奇怪的是,没有明确的方法来禁用这些模态对话框上的缓存。我不确定在网络浏览器中使用模态对话框是否被认为是一个“好主意”,但我们至少知道一些缺点和替代方案,但遗憾的是无法在这个项目中使用它们。
Thanks for your suggestions.
谢谢你的建议。
#4
2
Place Fiddler in between the IE and your server. Then check if the response to your request carries a HTTP header Cache-Control. Is there some value given other than no-cache ? If so then maybe IE will give this header priority over your http-equiv directive.
将Fiddler放在IE和服务器之间。然后检查对您的请求的响应是否带有HTTP头Cache-Control。除了没有缓存之外,还有其他值吗?如果是这样,那么IE可能会优先于你的http-equiv指令。
If not, you should try to make the server send the HTTP header Cache-Control:no-cache. If IE does not respect this, it's a bug in IE. Experience shows it's less painfull to opt for a different solution than to press for a bugfix, so in this case I'd agree to the tip of Greg.
如果没有,您应该尝试让服务器发送HTTP标头Cache-Control:no-cache。如果IE不尊重这一点,那就是IE中的一个错误。经验表明,选择不同的解决方案比按错误修复更少痛苦,所以在这种情况下我同意Greg的提示。
#5
2
First i tried by using the following code.
首先,我尝试使用以下代码。
meta http-equiv="Cache-Control" content="no-cache"
meta http-equiv="Pragma" content="no-cache"
meta http-equiv="Expires" content="-1"
but it was not given any solution after, i tried with Query String with time stamp variable, like
但之后没有给出任何解决方案,我尝试使用带有时间戳变量的Query String,就像
vat time = new Date().getTime();
url?queryString&time=time
then it works....
那它有效....
Thanks...
#6
1
you forgot a tag to reprocess the page.
你忘记了一个标签来重新处理页面。
<base target="_top" />
if you put below tags, the cache will be cleaned:
如果你把标签放在下面,缓存将被清除:
<meta http-equiv="Expires" content="0" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<base target="_top" />
#7
0
One of the strange quirks of IE is that setting no-cache at the beginning of the file doesn't seem to work, but moving that section to after the original HTML often does. Still best to send it as an HTTP header, but the following will work in most cases:
IE的一个奇怪的怪癖是在文件的开头设置no-cache似乎不起作用,但是将该部分移动到原始HTML之后常常会这样做。最好将其作为HTTP标头发送,但以下内容适用于大多数情况:
<html>
<head><title>Blah</title></head>
<body>Contents</body>
</html>
<html>
<head>
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
</head>
</html>
#8
0
The answer Response.Cache.SetCacheability(HttpCacheability.NoCache); is the only one that works correctly with IE9. If you set the timestamp in the querystring, you still have to refresh the page to get a different URL. So, the modal dialog is still cached until the page is refresh, unless you use Response.Cache.SetCacheability(HttpCacheability.NoCache); Using a timestamp on the URL and Response.Cache.SetCacheability(HttpCacheability.NoCache); would be best, cover all the bases. It is IE we're dealing with after all.
答案Response.Cache.SetCacheability(HttpCacheability.NoCache);是IE9中唯一可以正常工作的。如果在查询字符串中设置时间戳,则仍需刷新页面以获取不同的URL。因此,除非您使用Response.Cache.SetCacheability(HttpCacheability.NoCache),否则模式对话框仍会缓存,直到页面刷新为止。在URL和Response.Cache.SetCacheability(HttpCacheability.NoCache)上使用时间戳;将是最好的,覆盖所有的基础。毕竟这是我们正在处理的IE。
#9
0
You could also try the following statement at the top of the aspx page being called:
您还可以在被调用的aspx页面顶部尝试以下语句:
<%@ OutputCache Location="None" %>
#1
9
Add a timestamp querystring variable to the URL of the dialog content - number of ticks since 1/1/08 or something - IE will treat it as a new page and ignore the cache.
将时间戳查询字符串变量添加到对话框内容的URL中 - 自1/1/08以来的刻度数或其他内容 - IE将其视为新页面并忽略缓存。
#2
8
To clear cache add this in page load:
要清除缓存,请在页面加载中添加:
Response.Cache.SetCacheability(HttpCacheability.NoCache);
#3
4
Given that the http-equiv directives don’t work (and arguably shouldn’t be used), and despite it unfortunately being in the hack category of solutions, I think we are going to have to go with this (posted by Greg)...
鉴于http-equiv指令不起作用(并且可以说不应该使用),尽管不幸的是它属于黑客类别的解决方案,但我认为我们将不得不采用这种方式(由Greg发布)。 ..
url = "<Some url with query string>"
var date = new Date();
window.showModalDialog(url + “&” + date.getTime(), ... );
It is strange that there is no definitive way to disable caching on these modal dialogs. I’m not sure whether using modal dialogs in web browsers is accepted as a "good idea" or not, but we are aware of at least some of the shortcomings and alternatives, but are just unfortunately unable to use them in this project.
奇怪的是,没有明确的方法来禁用这些模态对话框上的缓存。我不确定在网络浏览器中使用模态对话框是否被认为是一个“好主意”,但我们至少知道一些缺点和替代方案,但遗憾的是无法在这个项目中使用它们。
Thanks for your suggestions.
谢谢你的建议。
#4
2
Place Fiddler in between the IE and your server. Then check if the response to your request carries a HTTP header Cache-Control. Is there some value given other than no-cache ? If so then maybe IE will give this header priority over your http-equiv directive.
将Fiddler放在IE和服务器之间。然后检查对您的请求的响应是否带有HTTP头Cache-Control。除了没有缓存之外,还有其他值吗?如果是这样,那么IE可能会优先于你的http-equiv指令。
If not, you should try to make the server send the HTTP header Cache-Control:no-cache. If IE does not respect this, it's a bug in IE. Experience shows it's less painfull to opt for a different solution than to press for a bugfix, so in this case I'd agree to the tip of Greg.
如果没有,您应该尝试让服务器发送HTTP标头Cache-Control:no-cache。如果IE不尊重这一点,那就是IE中的一个错误。经验表明,选择不同的解决方案比按错误修复更少痛苦,所以在这种情况下我同意Greg的提示。
#5
2
First i tried by using the following code.
首先,我尝试使用以下代码。
meta http-equiv="Cache-Control" content="no-cache"
meta http-equiv="Pragma" content="no-cache"
meta http-equiv="Expires" content="-1"
but it was not given any solution after, i tried with Query String with time stamp variable, like
但之后没有给出任何解决方案,我尝试使用带有时间戳变量的Query String,就像
vat time = new Date().getTime();
url?queryString&time=time
then it works....
那它有效....
Thanks...
#6
1
you forgot a tag to reprocess the page.
你忘记了一个标签来重新处理页面。
<base target="_top" />
if you put below tags, the cache will be cleaned:
如果你把标签放在下面,缓存将被清除:
<meta http-equiv="Expires" content="0" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<base target="_top" />
#7
0
One of the strange quirks of IE is that setting no-cache at the beginning of the file doesn't seem to work, but moving that section to after the original HTML often does. Still best to send it as an HTTP header, but the following will work in most cases:
IE的一个奇怪的怪癖是在文件的开头设置no-cache似乎不起作用,但是将该部分移动到原始HTML之后常常会这样做。最好将其作为HTTP标头发送,但以下内容适用于大多数情况:
<html>
<head><title>Blah</title></head>
<body>Contents</body>
</html>
<html>
<head>
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
</head>
</html>
#8
0
The answer Response.Cache.SetCacheability(HttpCacheability.NoCache); is the only one that works correctly with IE9. If you set the timestamp in the querystring, you still have to refresh the page to get a different URL. So, the modal dialog is still cached until the page is refresh, unless you use Response.Cache.SetCacheability(HttpCacheability.NoCache); Using a timestamp on the URL and Response.Cache.SetCacheability(HttpCacheability.NoCache); would be best, cover all the bases. It is IE we're dealing with after all.
答案Response.Cache.SetCacheability(HttpCacheability.NoCache);是IE9中唯一可以正常工作的。如果在查询字符串中设置时间戳,则仍需刷新页面以获取不同的URL。因此,除非您使用Response.Cache.SetCacheability(HttpCacheability.NoCache),否则模式对话框仍会缓存,直到页面刷新为止。在URL和Response.Cache.SetCacheability(HttpCacheability.NoCache)上使用时间戳;将是最好的,覆盖所有的基础。毕竟这是我们正在处理的IE。
#9
0
You could also try the following statement at the top of the aspx page being called:
您还可以在被调用的aspx页面顶部尝试以下语句:
<%@ OutputCache Location="None" %>