Why all the pages when I press back button ?

B

Bazza Formez

Hi there,
I am *very* new to this... so please excuse poor terminology etc.

I am building a small content management system.. and have just managed to
get an asp.net page up & running that edits / deleted data presented via a
datagrid via a datareader. All is well, the database is updated correctly..

However after merrily doing a few update cylces, I noticed afterwards that
when I pressed the back button on the browser, I was presented with a
"historical" page for each post cycle. Is there a way to stop this ? I don't
want to see any "history" in this way ...

Is this normal, or is there a setting to prevent this happening ?

Thanks,

Bazza
 
S

Steve C. Orr [MVP, MCSD]

There are several ways a page can be cached, and so there are several ways
you can specify for a page to not be cached.
This code has worked well for me:

Response.Expires = 0
Response.Cache.SetNoStore()
Response.AppendHeader("Pragma", "no-cache")
 
D

Dave Fancher

This is unfortunately one of the side-effects of using server-side
processing in a stateless environment. Nearly every action requires a
round-trip to the server. There's nothing you can really do about it short
of moving all of your logic to the client side and doing a batch update.

Here's the (short and extremely simplified) explanation of why this happens:
1.) User accesses page (page request, 1st history item added)
2.) User clicks "edit" for one of the items in the grid. The form submits
(another page request) so the page can be rerendered using text boxes,
etc... (2nd history item added)
3.) User makes changes and clicks "save." The form submits (another page
request) so the database can be updated and the grid redrawn with the
changes. (3rd history item added)
4.) User clicks "delete." The form is submitted (yet another page request)
so the item can be deleted from the database and the grid can be redrawn
with the changes
5.) ... you probably get the picture by now.

As you can see, each of these actions result in a page request, which causes
the browser to add an item to the history list.
 
D

Dave Fancher

....short of caching that is! Thanks Steve

I guess it's too late and I should be going to bed...
 
B

Bazza Formez

Thanks Steve.. I will try those settings.


Steve C. Orr said:
There are several ways a page can be cached, and so there are several ways
you can specify for a page to not be cached.
This code has worked well for me:

Response.Expires = 0
Response.Cache.SetNoStore()
Response.AppendHeader("Pragma", "no-cache")
 

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,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top