Page caching using Response.Expires = 0

G

Greg

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
 
B

Bob Lehmann

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.
What's a "comms error"

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

Bob Lehmann
 
G

Greg

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
 

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

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top