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?