I have developed a web application that processes credit card payments and when a user hits the back button in Fire Fox after they received the payment confirmation page, it post a duplicate payment.
I have put the following code in both the payment form and confirmation page and it still posts duplicate payments:
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();
What I am doing wrong and how can I resolve it?
rerun has a good point in the comments. With regards to this problem, try this code (source):
It should force all browsers to get the latest version and not the cached version of a page. (Might want to change the
Expiresdata has that post was from2006).