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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top