Page doesn't refresh after redirect.

Discussion in 'ASP .Net' started by seanmatthewwalsh@hotmail.com, May 12, 2008.

  1. Guest

    Hi

    I have a page (default.aspx) that pulls it's HTML from a database.

    I then have a "content management" page (editpage.aspx) that allows
    the user to edit the HTML in the database.

    When the user clicks the save button on editpage.aspx, the page
    updates the database and then redirects to the default.aspx page.

    However, on landing on the default.aspx page, the changes haven't been
    applied. Somewhere it has been cached. If I hit refresh or F5, then I
    get the updates.

    How do I get it to force a refresh / delete the cache?

    Thanks
    Sean
    , May 12, 2008
    #1
    1. Advertising

  2. When you redirect to the default page, add to the page url a random query
    parameter. This should trick the browser into loading the page from the
    server.

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    <> wrote in message
    news:...
    > Hi
    >
    > I have a page (default.aspx) that pulls it's HTML from a database.
    >
    > I then have a "content management" page (editpage.aspx) that allows
    > the user to edit the HTML in the database.
    >
    > When the user clicks the save button on editpage.aspx, the page
    > updates the database and then redirects to the default.aspx page.
    >
    > However, on landing on the default.aspx page, the changes haven't been
    > applied. Somewhere it has been cached. If I hit refresh or F5, then I
    > get the updates.
    >
    > How do I get it to force a refresh / delete the cache?
    >
    > Thanks
    > Sean
    Eliyahu Goldin, May 12, 2008
    #2
    1. Advertising

  3. Guest

    Hi

    I tried that, and it didn't work. I used a yyyymmddhhmmss parameter,
    and it still kept the original.

    Thanks tho. Any other ideas?

    Rgds
    Sean

    On May 12, 4:48 pm, "Eliyahu Goldin"
    <> wrote:
    > When you redirect to the default page, add to the page url a random query
    > parameter. This should trick the browser into loading the page from the
    > server.
    >
    > --
    > Eliyahu Goldin,
    > Software Developer
    > Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
    >
    > <> wrote in message
    >
    > news:...
    >
    >
    >
    > > Hi

    >
    > > I have a page (default.aspx) that pulls it's HTML from a database.

    >
    > > I then have a "content management" page (editpage.aspx) that allows
    > > the user to edit the HTML in the database.

    >
    > > When the user clicks the save button on editpage.aspx, the page
    > > updates the database and then redirects to the default.aspx page.

    >
    > > However, on landing on the default.aspx page, the changes haven't been
    > > applied. Somewhere it has been cached. If I hit refresh or F5, then I
    > > get the updates.

    >
    > > How do I get it to force a refresh / delete the cache?

    >
    > > Thanks
    > > Sean- Hide quoted text -

    >
    > - Show quoted text -
    , May 12, 2008
    #3
  4. Try to debug it to make sure the datasource gets reloaded from the database.

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    <> wrote in message
    news:...
    Hi

    I tried that, and it didn't work. I used a yyyymmddhhmmss parameter,
    and it still kept the original.

    Thanks tho. Any other ideas?

    Rgds
    Sean

    On May 12, 4:48 pm, "Eliyahu Goldin"
    <> wrote:
    > When you redirect to the default page, add to the page url a random query
    > parameter. This should trick the browser into loading the page from the
    > server.
    >
    > --
    > Eliyahu Goldin,
    > Software Developer
    > Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
    >
    > <> wrote in message
    >
    > news:...
    >
    >
    >
    > > Hi

    >
    > > I have a page (default.aspx) that pulls it's HTML from a database.

    >
    > > I then have a "content management" page (editpage.aspx) that allows
    > > the user to edit the HTML in the database.

    >
    > > When the user clicks the save button on editpage.aspx, the page
    > > updates the database and then redirects to the default.aspx page.

    >
    > > However, on landing on the default.aspx page, the changes haven't been
    > > applied. Somewhere it has been cached. If I hit refresh or F5, then I
    > > get the updates.

    >
    > > How do I get it to force a refresh / delete the cache?

    >
    > > Thanks
    > > Sean- Hide quoted text -

    >
    > - Show quoted text -
    Eliyahu Goldin, May 12, 2008
    #4
  5. Stan Guest

    On 12 May, 15:37, wrote:
    > Hi
    >
    > I have a page (default.aspx) that pulls it's HTML from a database.
    >
    > I then have a "content management" page (editpage.aspx) that allows
    > the user to edit the HTML in the database.
    >
    > When the user clicks the save button on editpage.aspx, the page
    > updates the database and then redirects to the default.aspx page.
    >
    > However, on landing on the default.aspx page, the changes haven't been
    > applied. Somewhere it has been cached. If I hit refresh or F5, then I
    > get the updates.
    >
    > How do I get it to force a refresh / delete the cache?
    >
    > Thanks
    > Sean


    You dont say how the redirection is occuring but to avoid client
    caching use Server.Transfer(default.aspx) rather than
    Response.Redirect(default.aspx) that way they get the new default.aspx
    page directly from the server.
    Stan, May 12, 2008
    #5
  6. Guest

    Thanks Stan, but also didn't work when I tried usign the
    server.transfer.

    I'm finding odd results. I have a line "This is line 1" in the
    database. I edit page, and change to "This is line12". The redirect/
    transfer takes me back to the page, and "This is line 1" is still
    showing.

    I click edit again. I change to "This is line 123" and press save. The
    redirect/transfer takes me to the page which now shows "This is line
    12". In the database, the HTML is stored as "This is line 123"
    though.

    Must be some caching issue.

    I put a breakpoint on the default.aspx file, at the point where the
    HTML is pulled from the DB and put in the file. I edit the page, and
    change to "This is line 1234", and on the transfer, the breakpoint
    stops execution. I check the Immediate window to see what the HTML
    from the recordset is, and it's "This is line 1234". I click the
    continue button, and the page shows properly as "This is line 1234".
    i.e. the debugging process seems to delete/override the cache.

    I even tried Response.Expires = -1 and
    HttpResponse.RemoveOutputCacheItem("/Default.aspx") to no avail.

    Thanks
    Sean


    On May 12, 5:21 pm, Stan <> wrote:
    > On 12 May, 15:37, wrote:
    >
    >
    >
    >
    >
    > > Hi

    >
    > > I have a page (default.aspx) that pulls it's HTML from a database.

    >
    > > I then have a "content management" page (editpage.aspx) that allows
    > > the user to edit the HTML in the database.

    >
    > > When the user clicks the save button on editpage.aspx, the page
    > > updates the database and then redirects to the default.aspx page.

    >
    > > However, on landing on the default.aspx page, the changes haven't been
    > > applied. Somewhere it has been cached. If I hit refresh or F5, then I
    > > get the updates.

    >
    > > How do I get it to force a refresh / delete the cache?

    >
    > > Thanks
    > > Sean

    >
    > You dont say how the redirection is occuring but to avoid client
    > caching use Server.Transfer(default.aspx) rather than
    > Response.Redirect(default.aspx) that way they get the new default.aspx
    > page directly from the server.- Hide quoted text -
    >
    > - Show quoted text -
    , May 12, 2008
    #6
  7. Guest

    Ok, the latest on this:

    I added a breakpoint to the default.aspx page AFTER the page retrieves
    the HTML from the database.

    I then edited the page through EditPage.aspx and clicked save.

    Now, the execution stops only AFTER the database has been accessed,
    and it appears the retrieved data from the database is the OLD
    version, i.e. it hasn't been updated. But if I open the database and
    check, or if I refresh the Default.aspx page, then the HTML in the DB
    is clearly the new version.

    It appears the access database hasn't written the changed data before
    the web server has already requested the page, so the page gets the
    old data before it has been overwritten. i.e. it's too quick for
    itself, or so it seems.

    Is this possible? What's the fix?

    Thanks

    On May 12, 5:31 pm, wrote:
    > Thanks Stan, but also didn't work when I tried usign the
    > server.transfer.
    >
    > I'm finding odd results. I have a line "This is line 1" in the
    > database. I edit page, and change to "This is line12". The redirect/
    > transfer takes me back to the page, and "This is line 1" is still
    > showing.
    >
    > I click edit again. I change to "This is line 123" and press save. The
    > redirect/transfer takes me to the page which now shows "This is line
    > 12". In the database, the HTML is stored as "This is line 123"
    > though.
    >
    > Must be some caching issue.
    >
    > I put a breakpoint on the default.aspx file, at the point where the
    > HTML is pulled from the DB and put in the file. I edit the page, and
    > change to "This is line 1234", and on the transfer, the breakpoint
    > stops execution. I check the Immediate window to see what the HTML
    > from the recordset is, and it's "This is line 1234". I click the
    > continue button, and the page shows properly as "This is line 1234".
    > i.e. the debugging process seems to delete/override the cache.
    >
    > I even tried Response.Expires = -1 and
    > HttpResponse.RemoveOutputCacheItem("/Default.aspx") to no avail.
    >
    > Thanks
    > Sean
    >
    > On May 12, 5:21 pm, Stan <> wrote:
    >
    >
    >
    > > On 12 May, 15:37, wrote:

    >
    > > > Hi

    >
    > > > I have a page (default.aspx) that pulls it's HTML from a database.

    >
    > > > I then have a "content management" page (editpage.aspx) that allows
    > > > the user to edit the HTML in the database.

    >
    > > > When the user clicks the save button on editpage.aspx, the page
    > > > updates the database and then redirects to the default.aspx page.

    >
    > > > However, on landing on the default.aspx page, the changes haven't been
    > > > applied. Somewhere it has been cached. If I hit refresh or F5, then I
    > > > get the updates.

    >
    > > > How do I get it to force a refresh / delete the cache?

    >
    > > > Thanks
    > > > Sean

    >
    > > You dont say how the redirection is occuring but to avoid client
    > > caching use Server.Transfer(default.aspx) rather than
    > > Response.Redirect(default.aspx) that way they get the new default.aspx
    > > page directly from the server.- Hide quoted text -

    >
    > > - Show quoted text -- Hide quoted text -

    >
    > - Show quoted text -
    , May 12, 2008
    #7
  8. Guest

    Yay!!

    I put the following line before my Response.Redirect:
    System.Threading.Thread.Sleep(1000);

    That delays execution for a second, and gives the database time to
    catch up!

    Sorted.

    Thanks for your efforts


    On May 12, 6:04 pm, wrote:
    > Ok, the latest on this:
    >
    > I added a breakpoint to the default.aspx page AFTER the page retrieves
    > the HTML from the database.
    >
    > I then edited the page through EditPage.aspx and clicked save.
    >
    > Now, the execution stops only AFTER the database has been accessed,
    > and it appears the retrieved data from the database is the OLD
    > version, i.e. it hasn't been updated. But if I open the database and
    > check, or if I refresh the Default.aspx page, then the HTML in the DB
    > is clearly the new version.
    >
    > It appears the access database hasn't written the changed data before
    > the web server has already requested the page, so the page gets the
    > old data before it has been overwritten. i.e. it's too quick for
    > itself, or so it seems.
    >
    > Is this possible? What's the fix?
    >
    > Thanks
    >
    > On May 12, 5:31 pm, wrote:
    >
    >
    >
    > > Thanks Stan, but also didn't work when I tried usign the
    > > server.transfer.

    >
    > > I'm finding odd results. I have a line "This is line 1" in the
    > > database. I edit page, and change to "This is line12". The redirect/
    > > transfer takes me back to the page, and "This is line 1" is still
    > > showing.

    >
    > > I click edit again. I change to "This is line 123" and press save. The
    > > redirect/transfer takes me to the page which now shows "This is line
    > > 12". In the database, the HTML is stored as "This is line 123"
    > > though.

    >
    > > Must be some caching issue.

    >
    > > I put a breakpoint on the default.aspx file, at the point where the
    > > HTML is pulled from the DB and put in the file. I edit the page, and
    > > change to "This is line 1234", and on the transfer, the breakpoint
    > > stops execution. I check the Immediate window to see what the HTML
    > > from the recordset is, and it's "This is line 1234". I click the
    > > continue button, and the page shows properly as "This is line 1234".
    > > i.e. the debugging process seems to delete/override the cache.

    >
    > > I even tried Response.Expires = -1 and
    > > HttpResponse.RemoveOutputCacheItem("/Default.aspx") to no avail.

    >
    > > Thanks
    > > Sean

    >
    > > On May 12, 5:21 pm, Stan <> wrote:

    >
    > > > On 12 May, 15:37, wrote:

    >
    > > > > Hi

    >
    > > > > I have a page (default.aspx) that pulls it's HTML from a database.

    >
    > > > > I then have a "content management" page (editpage.aspx) that allows
    > > > > the user to edit the HTML in the database.

    >
    > > > > When the user clicks the save button on editpage.aspx, the page
    > > > > updates the database and then redirects to the default.aspx page.

    >
    > > > > However, on landing on the default.aspx page, the changes haven't been
    > > > > applied. Somewhere it has been cached. If I hit refresh or F5, then I
    > > > > get the updates.

    >
    > > > > How do I get it to force a refresh / delete the cache?

    >
    > > > > Thanks
    > > > > Sean

    >
    > > > You dont say how the redirection is occuring but to avoid client
    > > > caching use Server.Transfer(default.aspx) rather than
    > > > Response.Redirect(default.aspx) that way they get the new default.aspx
    > > > page directly from the server.- Hide quoted text -

    >
    > > > - Show quoted text -- Hide quoted text -

    >
    > > - Show quoted text -- Hide quoted text -

    >
    > - Show quoted text -
    , May 12, 2008
    #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. Admin
    Replies:
    0
    Views:
    656
    Admin
    Jul 8, 2003
  2. TS
    Replies:
    8
    Views:
    990
    Wessel Troost
    Jul 27, 2005
  3. Orit
    Replies:
    1
    Views:
    466
    Masudur
    Jun 26, 2007
  4. Sal
    Replies:
    1
    Views:
    381
  5. Pkenty
    Replies:
    0
    Views:
    381
    Pkenty
    May 28, 2004
Loading...

Share This Page