I have a WebForms application where the first page is basically a grid containing links to a second page which loads up a PDF viewer. The grid is actually located in a .ascx control. Everything is working going from the first page to the PDF viewer page. However, when I hit the back button to return to the first page. I get the following error (in Chrome, but also this is happening in other browsers):
If I click the back button then the browser returns to the first page and everything is fine, but I need to resolve this error.
I have tried disabling the cache in the first page based on the recommendation from this StackOverflow answer, like so:
Response.AppendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0.
Response.AppendHeader("Expires", "0"); // Proxies.
I have also tried this:
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Cache.SetExpires(DateTime.MinValue);
I've placed this code in the code behind of the .aspx page and in the .ascx control (in the OnInit methods), all to no avail. What am I missing here?
The ERR_CACHE_MISS error is usually caused by a problem with the caching system, outdated extensions, or the wrong browser configuration. Usually, the issue is with your own browser or with a third party extension. As such, updating or resetting your browser or disabling extensions will usually fix the problem.
As @JJS implied it sounds like you are using a OnClick (possible via LinkButton or ImageButton) which is causing a partial/full postback and your redirect is occurring in the code-behind. If this is correct, is there a reason why you are not using HyperLinks?
Cache handling is not the fix. The browser is stating a post occurred between pages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With