Yet another Browser Back question

  • Thread starter Thread starter zdrakec
  • Start date Start date
Z

zdrakec

Hello all:

I note in my application, that when I use
Server.Transfer("somepage.aspx"), when the new page is loaded, and I
click the Back button on the browser, that the previous page, when it
displays, does not appear to have its Page_Load event fire. Neither
does the page which I am leaving have its Page_Unload event fire.

Additionally, there is a listbox on the first page that is populated
based on user-selected values. This listbox, populated at
Server.Transfer time, is blank upon using the browser's Back button.

a) Why does Page_Load not fire upon return to first page when the back
button is pushed?
b) Why is my listbox depopulated?

Thanks much,
zdrakec
 
Hi zdrakec, when you click the back button your browser is displaying locally
cached content and no call to the server is made. You could try to get around
it by setting a caching expiry date (in the past) or forcing _your_ browser
to always load afresh though this will not work for any one who hasnt also
got their browser set the same way HTH jd
 
Thank you london, can you describe precisely how one sets the caching
expiration date?

Thanks again,

zdrakec
 
Hello again, look at the response.cache object in particular:


Response.Cache.SetCacheability(HttpCacheability.*)

Response.Cache.SetExpires(myDate)

HTH jd
 
Thanks again london, please forgive me if I'm being a bit dense, but
I'm not sure WHERE to set this...in the second page's load event, or in
the same procedure that executes Server.Transfer?

Cheers,

zdrakec
 
zdrakec said:
Thanks again london, please forgive me if I'm being a bit dense, but
I'm not sure WHERE to set this...in the second page's load event, or
in the same procedure that executes Server.Transfer?

Cheers,

zdrakec

You set it in the page or code-behind class that produces the
HttpResponse, i.e. the actual output received by the client.

Cheers
 
private void Page_Load(object sender, System.EventArgs e)
{
ExpirePageCache();
//.......rest of the page_load logic....................
}


/// <summary>
/// This function prevent the page being retrieved from broswer cache
/// </summary>
private void ExpirePageCache()
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now-new TimeSpan(1,0,0));
Response.Cache.SetLastModified(DateTime.Now);
Response.Cache.SetAllowResponseInBrowserHistory(false);
}
 
Back
Top