Expiring a page to control the use of the Back button
I'm trying to expire pages in my application so when a user clicks the back button they will be forced to refresh.
I have the code:
Response.Expires = -1
Response.CacheControl = "no-cache"
in the page_load, outside of the postback handling, but it isn't giving me the results I expected (I have seen this used on an application that I worked on for a previous employer).
When I clicked the back button, I was expecting to get a message saying "Warning: Page has expired. Please click retry to refresh or cancel" (or something like that).
So, I'm not sure if I'm missing something or what?
I added the meta tag and checked that the response properties/methods were the same as what you suggested, but it still didn't work.
Is there a property in the @ Page directive that I may need?
Here is what it is right now:
<%@ Page Language="vb" AutoEventWireup="false" SmartNavigation="True" Codebehind="myPage1.aspx.vb" Inherits="myApp.myPage1" %>
(I tried removing SmartNavigation, but it didn't help either).
Is there anything in the Web.Config that would affect this?
I've done some more testing. I think I'm just not seeing the results that I'm expecting - WHEN I'm expecting them.
I was thinking that I would see the Page Expiration message when I went back from one page to another, but I don't. Right now, I'm seeing the Expiration message when I'm on a page and I go back after I've handled an IndexChanged event for a radio button.
The other page that I'm working with has frames and I suspect that might be part of the reason why the page is not expiring or not expiring when I expect it to.
I got the same error. Can you tell me who do you doing or some one resolve that problem. I 'm trying to resolve, but nothing works. I added meta tag's(HTML) and code behid(set response) and configuring IIS(HTTP Headers). I only need seeing the Expiration message when I'm on a page and I go back.