Yet another Browser Back question

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
 
G

Guest

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
 
Z

zdrakec

Thank you london, can you describe precisely how one sets the caching
expiration date?

Thanks again,

zdrakec
 
G

Guest

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


Response.Cache.SetCacheability(HttpCacheability.*)

Response.Cache.SetExpires(myDate)

HTH jd
 
Z

zdrakec

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
 
J

Joerg Jooss

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
 
G

Guest

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);
}
 

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,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top