Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/258.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.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中禁用Fire Fox中的缓存#_C#_Asp.net_Firefox_Caching - Fatal编程技术网

C# 在ASP.NET和C中禁用Fire Fox中的缓存#

C# 在ASP.NET和C中禁用Fire Fox中的缓存#,c#,asp.net,firefox,caching,C#,Asp.net,Firefox,Caching,我开发了一个处理信用卡付款的web应用程序,当用户在收到付款确认页面后点击Fire Fox中的后退按钮时,它会发布重复付款 我在付款表单和确认页面中都添加了以下代码,但仍然会发布重复付款: Response.Cache.SetExpires(DateTime.UtcNow.AddYears(-1)); Response.Cache.SetValidUntilExpires(false); Response.Cache.SetRevalidation(HttpCacheRevalidation.A

我开发了一个处理信用卡付款的web应用程序,当用户在收到付款确认页面后点击Fire Fox中的后退按钮时,它会发布重复付款

我在付款表单和确认页面中都添加了以下代码,但仍然会发布重复付款:

Response.Cache.SetExpires(DateTime.UtcNow.AddYears(-1));
Response.Cache.SetValidUntilExpires(false);
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
Response.Cache.SetAllowResponseInBrowserHistory(false);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();

我做错了什么以及如何解决它?

重新运行在评论中有一个很好的观点。关于此问题,请尝试以下代码():


它应该强制所有浏览器获取页面的最新版本,而不是缓存版本。(可能需要更改
过期日期
数据,该帖子来自
2006
)。

有关不执行重复处理的更一般性问题,请阅读中给出的建议


总之,有几种方法可以尝试阻止客户端浏览器重复请求,但最终,如果绝对重要的是提交不会被处理两次,那么您需要在服务器端检查是否已经处理了付款。在他们提交的表单中添加一个唯一标识符,将其记录到数据库中,如果第二次看到相同的标识符,则不要处理该请求。

问题不在于缓存,而在于缓存副本可能会重复支付。Michael,首先,我将尝试此附加组件以检查缓存设置是否达到预期效果:
   Response.ClearHeaders();
   Response.AppendHeader("Cache-Control", "no-cache"); //HTTP 1.1
   Response.AppendHeader("Cache-Control", "private"); // HTTP 1.1
   Response.AppendHeader("Cache-Control", "no-store"); // HTTP 1.1
   Response.AppendHeader("Cache-Control", "must-revalidate"); // HTTP 1.1
   Response.AppendHeader("Cache-Control", "max-stale=0"); // HTTP 1.1 
   Response.AppendHeader("Cache-Control", "post-check=0"); // HTTP 1.1 
   Response.AppendHeader("Cache-Control", "pre-check=0"); // HTTP 1.1 
   Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.1 
   Response.AppendHeader("Keep-Alive", "timeout=3, max=993"); // HTTP 1.1 
   Response.AppendHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); // HTTP 1.1