Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何完全刷新ASP.NET页面,以便再次运行页面加载?_C#_Asp.net_Caching_Browser - Fatal编程技术网

C# 如何完全刷新ASP.NET页面,以便再次运行页面加载?

C# 如何完全刷新ASP.NET页面,以便再次运行页面加载?,c#,asp.net,caching,browser,C#,Asp.net,Caching,Browser,我有一个ASP.NET页面,其中动态设置了iframe src: <iframe id="specialframe" src="<%= IframeSrc %>"></iframe> SpecialService是一种第三方服务,调用该服务时返回一个一次性使用的URL,该URL类似于: http://www.specialservice.com/oneTimeUseId=fh8396123lkjufgh49 出于安全目的,此ID在过期之前只能使用一次。然而

我有一个ASP.NET页面,其中动态设置了iframe src:

<iframe id="specialframe" src="<%= IframeSrc %>"></iframe>
SpecialService
是一种第三方服务,调用该服务时返回一个一次性使用的URL,该URL类似于:

http://www.specialservice.com/oneTimeUseId=fh8396123lkjufgh49
出于安全目的,此ID在过期之前只能使用一次。然而,这导致了一个问题

第一次在浏览器中显示页面时,它会正确加载iframe。但是,如果我点击刷新,我将在iframe中收到一条错误消息,因为它试图使用相同的一次性使用ID。如果我按下Ctrl+F5刷新以强制清除缓存,它将正常工作,但我不能告诉我的用户每次都这样做


我的问题是,是否可以强制浏览器从不使用缓存并始终从服务器请求新副本?

您需要正确设置页面的过期和缓存,以便浏览器始终必须从服务器请求页面

这个问题也许是个好的开始

您需要将cacheability设置为none(并且可能在过去设置expiration,也可能设置maxage):

http://www.specialservice.com/oneTimeUseId=fh8396123lkjufgh49
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddMinutes(-30));