dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: Expiring a page to control the use of the Back button

  1. #1
    Join Date
    Sep 2004
    Location
    PEI, Canada
    Posts
    13

    Expiring a page to control the use of the Back button

    Hi,

    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.Cache.SetCacheability(HttpCacheability.Server)
    Response.Expires = -1
    Response.AddHeader("Pragma", "No-Cache")
    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?

    Thanks,
    MWhalen

  2. #2
    Join Date
    Sep 2004
    Location
    localhost
    Posts
    47

    Lightbulb refresh

    make sure this is at top of page:

    Response.CacheControl = "no-cache" 'no-cache
    Response.AddHeader "Pragma","no-cache"
    Response.Expires = 0
    Response.Buffer=true


    and throw in:

    <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">

  3. #3
    Join Date
    Sep 2004
    Location
    PEI, Canada
    Posts
    13
    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?

  4. #4
    Join Date
    Sep 2004
    Location
    PEI, Canada
    Posts
    13
    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.

  5. #5
    Join Date
    Mar 2006
    Posts
    1

    Same Error(Expiration Page)

    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles