By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,561 Members | 3,010 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,561 IT Pros & Developers. It's quick & easy.

Page caching using Response.Expires = 0

P: n/a
Hi

I'd like to stop a particular ASP page from being stored in the history so
visitors cannot use their browser's back button to return to it. I've used
Response.Expires = 0 along with this:

Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1

And neither of them seem to work.

Forgive me if I seem a little dumb, but is this possible?

The page in question is where a customer's gift voucher gets redeemed. Some
vouchers have a set number of times they can be used, and I want to stop
users going back to the page to redeem it again if there was a comms error
and they didn't make it to the next page for some reason. Any ideas?

Is there also a way of detecting that they have been disconnected or a
problem has occurred, and thus allowing them to use their voucher again. I
have already sorted it with a bit of JavaScript so that the "Redeem" button
can only be clicked once.

Kind regards,
Greg
Jul 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
>>but is this possible?
No. You cannot prevent pages from being added to the history with ASP. You
may be able to find some client-side code - I don't know.
if there was a comms error
What's a "comms error"

Why don't you just track the voucher redemption in a database?

Bob Lehmann

"Greg" <te**@jmswebdesigns.com> wrote in message
news:%2******************@TK2MSFTNGP15.phx.gbl... Hi

I'd like to stop a particular ASP page from being stored in the history so
visitors cannot use their browser's back button to return to it. I've used
Response.Expires = 0 along with this:

Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1

And neither of them seem to work.

Forgive me if I seem a little dumb, but is this possible?

The page in question is where a customer's gift voucher gets redeemed. Some vouchers have a set number of times they can be used, and I want to stop
users going back to the page to redeem it again if there was a comms error
and they didn't make it to the next page for some reason. Any ideas?

Is there also a way of detecting that they have been disconnected or a
problem has occurred, and thus allowing them to use their voucher again. I
have already sorted it with a bit of JavaScript so that the "Redeem" button can only be clicked once.

Kind regards,
Greg

Jul 21 '05 #2

P: n/a
Hi

Don't think I was that clear when writing my initial post. Sorry! I'll try
to be more descriptive and to the point!

The voucher codes are stored in a table "VOUCHER" in my database, and when a
voucher is redeemed it's "NumberOfUses" field is decremented. If this field
is currently set to 1, it is then set to -1 and not 0 to indicate that the
voucher has become invalid. If the value is 0, the voucher has no usage
limit.

When the user clicks the "Redeem" button, I forward to a page which changes
the value of the "NoOfUses" field. This works fine and produces the desired
result.

However, assume that the user redeems a voucher that can be used twice, ie.
"NoOfUses" is set to 2. When they click "Redeem" the field's value is set to
1 by the page they are redirected to. There is nothing stopping the user
from using the back button of their browser to return to the page with the
"Redeem" button on it, and redeem the voucher again. They may need to do
this if an error had occurred at the server or they had lost their Internet
connection preventing the next page from displaying correctly.

I already have a warning next to the "Redeem" button stating that it should
only be clicked once and that if the user has any problems they should NOT
to press it again, instead they should contact the company who can issue
them with another voucher.

I was just wondering if there was a way to prevent the same voucher being
redeemed in the same session. As I'm writing this I am thinking that I could
set a session variable to use as a flag saying that a voucher has been
redeemed, and that if it is set, don't let it be redeemed again!

Any thoughts?

Kind regards,
Greg
Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.