page expiration

K

kpg

Hi all, easy question:

How can I make a page expire immediately?

I don't want the user to be able to re-visit it.

Tried <% response.expires = 0 %>, did not work.

Don't understand how to use the System.Web.HttpCachePolicy

???

Thanks
kpg
 
K

Kim Quigley

Setting Response.Expires to 0 just makes it so the browser doesn't cache the
page, which doesn't sound at all like the solution to your problem.

Are you saying that if someone sees a certain page, then if they refresh or
return to it, you want them to see something else or be redirected?
 
K

kpg

Setting Response.Expires to 0 just makes it so the browser doesn't cache
the page, which doesn't sound at all like the solution to your problem.

Are you saying that if someone sees a certain page, then if they refresh
or return to it, you want them to see something else or be redirected?

After the user logs on I show a page that displays a list of items
previously
saved. When the user picks one I redirect them to a page with the selected
data loaded to begin processing. If they hit the back button (history) of
the
browser and try to revisit the item list page I want to show that it has
expired.
There should be no way for them to return to this page unless they logoff
and then back on.

If the page were not cached then the request would come to the server
and I could display a message. My problem is I put a response.expires =0
and I still got the cached page. Maybe I was using it wrong. I added it to
the top of the html page before the <head>. I also tried adding a
response.expires = 0 into the page load event with the same effect (none).

Hope that clears it up.

Thanks,
kpg
 
H

hashimisayed

When they visit the page, put a variable on the session to indicate
that they have vitited. When they come back, the session will have the
value and you can display an appropriate message.


sayed
 
K

Kim Quigley

The problem with the back button is an age old issue and I'm very interested
to see if anyone is going to offer you a solution. When a user clicks the
back button, the page doesn't reload, so no code is executed.
 
S

Steve C. Orr [MVP, MCSD]

Try this code:
Response.Expires = 0
Response.Cache.SetNoStore()
Response.AppendHeader("Pragma", "no-cache")
 
J

Joerg Jooss

kpg said:
Hi all, easy question:

How can I make a page expire immediately?

I don't want the user to be able to re-visit it.

Tried <% response.expires = 0 %>, did not work.

Don't understand how to use the System.Web.HttpCachePolicy

HttpResponse has a "Cache" property which is a instance if
HttpCachePolicy. You should set your caching options through this
object, e.g.

Response.Cache.SetCacheability(HttpCacheability.NoCache);

Cheers,
 
J

Joerg Jooss

kpg said:
OK. Here it is.

Put this in the page load event: Response.Cache.SetNoStore()

This prevents the browser from caching the page, which
means I will always get the hit when the page is reloaded.

Note that there's no guarantee that this works across all browsers.

Cheers,
 
J

\jason via DotNetMonster.com\

add this line to ur html coding
it will prevent user from hitting the back button of our browser...



<body onload="history.go(+1)" MS_POSITIONING="GridLayout">


try it and c whether it has any affect?

email me at

(e-mail address removed)
 
J

\jason via DotNetMonster.com\

add this line to ur html coding
it will prevent user from hitting the back button of our browser...



<body onload="history.go(+1)" MS_POSITIONING="GridLayout">


try it and c whether it has any affect?

email me at

(e-mail address removed)
Kim said:
The problem with the back button is an age old issue and I'm very interested
to see if anyone is going to offer you a solution. When a user clicks the
back button, the page doesn't reload, so no code is executed.
[quoted text clipped - 24 lines]
Thanks,
kpg
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top