Response.Expires and Response.Cache

  • Thread starter Thread starter Promenade
  • Start date Start date
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
 
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")
 
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.....
 
Back
Top