Response.Expires and Response.Cache

P

Promenade

Hi, everyone...
I want to avoid the user to use the navigator back button.
For that reason, I tried all the possible ways to set the Expires property
of the Response Object, but whatever I do, it does not work for me.

In fact, it does work once, the first time I wrote these lines in the
Application_BeginRequest event of the Global.asax file:
Response.Buffer = True
Response.ExpiresAbsolute = Now().Subtract(New TimeSpan(1, 0, 0, 0))
Response.Expires = 0 'or -1
Response.CacheControl = "no-cache"

But since I re-compiled the code, it never worked again.

I also wrote these lines everywhere:

Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetExpires(Now())

In the Page:
Page_Load
Page_PreRender

In the Global.asax:
Session_Start
Application_BeginRequest
Application_AuthenticateRequest
Application_Error
Session_End
Global_AcquireRequestState

I also had tried with the following code:

Response.AddHeader("Pragma", "no-cache")
Response.AddHeader("Expires", "-1")

Nothing.
I appreciate any suggestion.

Promenade
 
S

Steve C. Orr [MVP, MCSD]

Clear your browser cache. You may have some funky old stuff cached in there
since you've been messing around with this stuff.

Then try this code:
Response.Expires = 0
Response.Cache.SetNoStore()
Response.AppendHeader("Pragma", "no-cache")
 
P

Promenade

Steve, thank you for your response. I'm sorry to say that didn´t work.
I don't even have a clue of what is happening here, maybe I'm doing
something wrong, the odd thing is that it worked once.....
 

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,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top