expiring an aspx page

J

James

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
 
J

James

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
 
K

Kevin Spencer

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top