expiring an aspx page

Discussion in 'ASP .Net' started by James, Aug 27, 2003.

  1. James

    James Guest

    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, Aug 27, 2003
    #1
    1. Advertising

  2. James

    James Guest

    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" <> wrote in message
    news:...
    > I'm afraid you're barking up the wrong tree here. That error occurs when

    you
    > try to refresh or navigate back toa page which was returned from the

    server
    > as a result of a form POST operation. Since the page resulted form a POST
    > operation, the only way to re-load it is to rePOST the form. It can be a
    > problem with ASP.Net apps, because ASP.Net pages post back to themselves.

    It
    > makes using JavaScript History and the Back button of the browser
    > problematic.
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > .Net Developer
    > http://www.takempis.com
    > The more I learn, the less I know.
    >
    > "James" <> wrote in message
    > news:...
    > > 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, Aug 27, 2003
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    > > I'm afraid you're barking up the wrong tree here. That error occurs when

    > you
    > > try to refresh or navigate back toa page which was returned from the

    > server
    > > as a result of a form POST operation. Since the page resulted form a

    POST
    > > operation, the only way to re-load it is to rePOST the form. It can be a
    > > problem with ASP.Net apps, because ASP.Net pages post back to

    themselves.
    > It
    > > makes using JavaScript History and the Back button of the browser
    > > problematic.
    > >
    > > --
    > > HTH,
    > >
    > > Kevin Spencer
    > > Microsoft MVP
    > > .Net Developer
    > > http://www.takempis.com
    > > The more I learn, the less I know.
    > >
    > > "James" <> wrote in message
    > > news:...
    > > > 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
    > > >
    > > >

    > >
    > >

    >
    >
     
    Kevin Spencer, Aug 27, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Natty Gur

    Re: expiring a page

    Natty Gur, Jul 2, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    425
    Natty Gur
    Jul 2, 2003
  2. George Smith

    Expiring the page......

    George Smith, May 18, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    522
    George Smith
    May 18, 2005
  3. tshad

    Page expiring

    tshad, Nov 29, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    504
    Charles
    Nov 29, 2005
  4. Chris

    Expiring Page

    Chris, Jun 3, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    404
    Chris
    Jun 4, 2007
  5. =?Utf-8?B?Vk1J?=

    Expiring page immediately after leaving it...

    =?Utf-8?B?Vk1J?=, Nov 11, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    408
    Cowboy \(Gregory A. Beamer\)
    Nov 13, 2007
Loading...

Share This Page