Yet another Browser Back question

Discussion in 'ASP .Net' started by zdrakec, Jul 7, 2005.

  1. zdrakec

    zdrakec Guest

    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
     
    zdrakec, Jul 7, 2005
    #1
    1. Advertising

  2. 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

    "zdrakec" wrote:

    > 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
    >
    >
     
    =?Utf-8?B?bG9uZG9uIGNhbGxpbmc=?=, Jul 7, 2005
    #2
    1. Advertising

  3. zdrakec

    zdrakec Guest

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

    Thanks again,

    zdrakec
     
    zdrakec, Jul 8, 2005
    #3
  4. Hello again, look at the response.cache object in particular:


    Response.Cache.SetCacheability(HttpCacheability.*)

    Response.Cache.SetExpires(myDate)

    HTH jd

    "zdrakec" wrote:

    > Thank you london, can you describe precisely how one sets the caching
    > expiration date?
    >
    > Thanks again,
    >
    > zdrakec
    >
    >
     
    =?Utf-8?B?bG9uZG9uIGNhbGxpbmc=?=, Jul 8, 2005
    #4
  5. zdrakec

    zdrakec Guest

    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, Jul 8, 2005
    #5
  6. zdrakec

    Joerg Jooss Guest

    zdrakec wrote:

    > 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
    --
    http://www.joergjooss.de
    mailto:
     
    Joerg Jooss, Jul 8, 2005
    #6
  7. zdrakec

    zdrakec Guest

    Thank you sir!
     
    zdrakec, Jul 8, 2005
    #7
  8. 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);
    }


    "zdrakec" wrote:

    > 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
    >
    >
     
    =?Utf-8?B?U3JlZWppdGggUmFt?=, Jul 12, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Martin
    Replies:
    3
    Views:
    407
    Martin
    Jul 24, 2003
  2. Serdar C.
    Replies:
    2
    Views:
    523
    Serdar C.
    May 8, 2005
  3. Berehem
    Replies:
    4
    Views:
    592
    Lawrence Kirby
    Apr 28, 2005
  4. Author
    Replies:
    6
    Views:
    3,255
    George
    Jan 22, 2009
  5. David Mark

    Yet another appeal for browser sniffing

    David Mark, Nov 1, 2011, in forum: Javascript
    Replies:
    6
    Views:
    603
    David Mark
    Nov 3, 2011
Loading...

Share This Page