Professional Web Applications Themes

expiring an aspx page - ASP.NET General

I've been to websites where if I navigate off a form, trying to get back to it by hitting the back button gives me a page which says "Warning, page has expired". It doesn't display the page. I've been searching around trying to get this to happen for one of my aspx pages and I can't get it to expire. I've put the following HTML tags in the page: <meta http-equiv="expires" content="Sun, Dec 31 1970 12:00:00 GMT"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="pragma" content="no-cache"> and the following code in the Page_Load subroutine Response.Expires = -1 but it both cases, I can ...

  1. #1

    Default expiring an aspx page

    I've been to websites where if I navigate off a form, trying to get back to
    it by hitting the back button gives me a page which says "Warning, page has
    expired". It doesn't display the page. I've been searching around trying
    to get this to happen for one of my aspx pages and I can't get it to expire.
    I've put the following HTML tags in the page:

    <meta http-equiv="expires" content="Sun, Dec 31 1970 12:00:00 GMT">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="pragma" content="no-cache">

    and the following code in the Page_Load subroutine
    Response.Expires = -1

    but it both cases, I can alter the state of controls on the page, click a
    button taking me to a different page, and then click the back button and it
    returns me to the page with my alterations still intact. Can anyone explain
    how I can make it so that the page will expires?

    Thanks,

    James


    James Guest

  2. #2

    Default Re: expiring an aspx page

    Maybe I didn't explain good enough. First, I don't want to reload the form.
    I want to stop the user from being able to nagivate back to an intact page.
    Here's the scenario:

    User navigates to page X. Page X loads, filling a datagrid with some link
    buttons and checkboxes in each row. They check some boxes and click a link
    button. This causes two things to happen. First, a subroutine of page X
    executes and makes changes to a database based on the checkboxes the user
    checked. Second, I do a response redirect to page Y.

    What happens next is the problem. The user is able to hit back and go back
    to page X where the original rows are still in the datagrid and the
    checkboxes they checked are still checked (which, due to the aforementioned
    database update, should not even appear in the grid if the page were loaded
    new). They then click a button and post the same checked columns, which is
    causing duplicate entries. I want to prevent them from getting back to that
    page once they navigate away from it. I can't just code the database to
    test for duplicate entries, because they are legally allowed by the business
    rules. But these dupes are unintentional and a result of being able to
    navigate back to a page and repost the same data after its been posted. I
    just want to expire the page.

    Thanks,

    James

    "Kevin Spencer" <com> wrote in message
    news:phx.gbl... 
    you 
    server 
    It 
    > to 
    > has [/ref]
    trying 
    > expire. [/ref]

    > it 
    > explain 
    >
    >[/ref]


    James Guest

  3. #3

    Default Re: expiring an aspx page

    What I was trying to tell you is that you CAN'T expire a page. There are
    some things you can do to prevent navigating back to it, however, such as
    using the JavaScript location.replace() function to navigate to the new
    page. That can be tricky, though, as it must be done on the client. One
    method is to use RegisterStartupScript() in place of Response.Redirect in
    your code. Instead of sending a Response.Redirect, you can construct a
    JavaScript location.Replace() function and have it run when the page loads
    in the browser. This function overwrites the client-side history object for
    that page, effectively disabling the ability to use the back button to
    navigate back to it. Another alternative is to use Server.Tranfer instead of
    Response.Redirect. This method invokes the second page without telling the
    browser. As far as the browser is concerned, it is still on the same page,
    even though the contents have changed.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    http://www.takempis.com
    The more I learn, the less I know.

    "James" <com> wrote in message
    news:phx.gbl... 
    form. 
    page. 
    link 
    back 
    aforementioned 
    loaded 
    is 
    that 
    business 
    > you 
    > server [/ref]
    POST [/ref]
    themselves. [/ref][/ref]
    back [/ref][/ref]
    page [/ref]
    > trying 
    > > expire. [/ref][/ref]
    click [/ref][/ref]
    and 
    > > explain 
    > >
    > >[/ref]
    >
    >[/ref]


    Kevin Guest

Similar Threads

  1. Expiring Page After transaction
    By capik79 in forum Macromedia ColdFusion
    Replies: 2
    Last Post: June 14th, 03:51 AM
  2. Replies: 0
    Last Post: June 12th, 10:47 PM
  3. Injecting image page element without calling ASPX page?
    By Christopher in forum ASP.NET General
    Replies: 2
    Last Post: August 27th, 04:15 PM
  4. expiring a page
    By Natty Gur in forum ASP.NET General
    Replies: 0
    Last Post: July 2nd, 03:59 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139