Expire problem

G

Gonçalo Boléo

I have a page (page1.aspx) with some content.
The user select the content and press a next button and is redirected to
another page (page2.axpx).

I wan't that page1.aspx is not redisplayed when i press the back button in
my browser when i am in page2.aspx.

How do i do this?

thanks,
Gonçalo Boléo
 
J

John Timney \(ASP.NET MVP\)

Normally code like this can be used.

<%
System.Web.HttpContext.Current.Response.AddHeader("Cache-Control","no-cache"
)
System.Web.HttpContext.Current.Response.Expires = 0
System.Web.HttpContext.Current.Response.Cache.SetNoStore()
System.Web.HttpContext.Current.Response.AddHeader("Pragma", "no-cache")%>

However, expiry is rarely a very reliable thing depending on the browser,
its worth reading this:

http://www.mnot.net/cache_docs/

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
J

Joerg Jooss

Gonçalo Boléo said:
I have a page (page1.aspx) with some content.
The user select the content and press a next button and is redirected
to another page (page2.axpx).

I wan't that page1.aspx is not redisplayed when i press the back
button in my browser when i am in page2.aspx.

How do i do this?

In general, you can't. Quoting the HTTP 1.1 spec:

"[...] a history mechanism is meant to show exactly what the user saw
at the time when the resource was retrieved".

Not that most browsers actually implement this behaviour -- AFAIK only
Opera does. Other browsers can be convinced at least to reload the page
by making it non-cacheable (see John's post). But trying to make the
page disappear requires additional logic for page1.aspx.


Cheers,
 

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

Top