Page doesn't refresh after redirect.

S

seanmatthewwalsh

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
 
S

seanmatthewwalsh

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

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




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 -
 
E

Eliyahu Goldin

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


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

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




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 -
 
S

Stan

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

seanmatthewwalsh

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
 
S

seanmatthewwalsh

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
 
S

seanmatthewwalsh

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
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top