No-Cache and Expiry

G

Gareth

Does anyone know how to make an ASP.NET (C#) page expire immediately and not
be cached?
What I want to happen is if the users pressed the BACK button they get a
page has expired and has to be reloaded message.
I've tried just placing the standard HTML meta tags in but that doesn't seem
to work. I've also tried using the Cache objects properties too. That didn't
seem to work either.

Anyone any ideas?

Thanks,
Gareth
 
T

Tommy

Place the following code at the top of your aspx page.

<% 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")%>

Tommy,
 

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,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top