469,578 Members | 1,759 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,578 developers. It's quick & easy.

OutputCache Back Button Page Expires

Hello!

I am having a problem with the @OutputCache page directive and Web
browser Back Buttons.

Problem:

After setting <%@ OutputCache Location="None" %> on my pages I get the
"Warning! Page has expired" error message, when pushing the Back
Button in my Web browser.

After reading several posts on the subject I found a solution to the
problem.

Solution:

Enable SmartNavigation on the page I am browsing back to. This
solution actually work, which is good.

But I am not completely satisfied. I have worked with smart navigation
before, and smart navigation has a tendency to lead to problems (at
least when I use it...), and my original idea seemed to good to
surender to smart navigation.

Background:

I am implementing a classic Web Shop, and I have the shopping cart
implemented as a UserControl. The cart can be added to (or deleted
from) on different pages in the Shop. If the OutputCache is not set to
Location="None", Page_Load doesn't fire when you push the Back Button
(since the page is cached), and if you have added to the cart and push
back, changes to the cart is not visible to the user (especially if
you switch to a different page) since Page_Load is not fired, and the
cart can't be rebound to reflect the changes to the cart.

(I have developed a framework similar to the UIP Application Block
which works very well and keeps state updated between pages)

I thought the purpose of the Location="None" setting was to trigger
the Page_Load event on the pages, not to trigger a pointless error
message to the user. Pointless beacuse if the user repeatedly push the
back button, the desired page is shown (with cart updated).

Questions:

Is there a way to work around my "problem" without using the
SmartNavigation feature?

And can someone explain why the Location="None" setting isn't working
like I wan't it to, I mean, I think my desired behavior is pretty
straight forward?

Final question: Is there a better way? :)

/ Johan Nedin
Nov 18 '05 #1
1 6170
if you set OutputCache Location="None", you are telling everyone (browser,
proxy server and asp.net) to not cache the page.

when the user hit back on an aspx page that displayed from a postback, the
browser knows it has to repost the data to get a fresh version of the page.
as so many people wrote bad web sites that could not handle this case
(double charge cc cards, double order, etc), the browsers added this
warning. how many sites have you gone to where they say don't click twice or
hit back (these poorly coded sites are the why the browsers had to get
defensive).

so we all have to pay for bad coding practices, sorry.

i would not use smartnav, but if you are tempted, know that it just uses an
iframe to hid the nav history, so you could design your site as a framed
site and hid the nav history.

-- bruce (sqlwork.com)

"Johan Nedin" <ra*********@hotmail.com> wrote in message
news:2b**************************@posting.google.c om...
Hello!

I am having a problem with the @OutputCache page directive and Web
browser Back Buttons.

Problem:

After setting <%@ OutputCache Location="None" %> on my pages I get the
"Warning! Page has expired" error message, when pushing the Back
Button in my Web browser.

After reading several posts on the subject I found a solution to the
problem.

Solution:

Enable SmartNavigation on the page I am browsing back to. This
solution actually work, which is good.

But I am not completely satisfied. I have worked with smart navigation
before, and smart navigation has a tendency to lead to problems (at
least when I use it...), and my original idea seemed to good to
surender to smart navigation.

Background:

I am implementing a classic Web Shop, and I have the shopping cart
implemented as a UserControl. The cart can be added to (or deleted
from) on different pages in the Shop. If the OutputCache is not set to
Location="None", Page_Load doesn't fire when you push the Back Button
(since the page is cached), and if you have added to the cart and push
back, changes to the cart is not visible to the user (especially if
you switch to a different page) since Page_Load is not fired, and the
cart can't be rebound to reflect the changes to the cart.

(I have developed a framework similar to the UIP Application Block
which works very well and keeps state updated between pages)

I thought the purpose of the Location="None" setting was to trigger
the Page_Load event on the pages, not to trigger a pointless error
message to the user. Pointless beacuse if the user repeatedly push the
back button, the desired page is shown (with cart updated).

Questions:

Is there a way to work around my "problem" without using the
SmartNavigation feature?

And can someone explain why the Location="None" setting isn't working
like I wan't it to, I mean, I think my desired behavior is pretty
straight forward?

Final question: Is there a better way? :)

/ Johan Nedin

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

29 posts views Thread by Tom wilson | last post: by
1 post views Thread by Liming | last post: by
1 post views Thread by nileshsoni21 | last post: by
5 posts views Thread by Arpan | last post: by
2 posts views Thread by Nalaka | last post: by
1 post views Thread by Nalaka | last post: by
3 posts views Thread by =?Utf-8?B?TWlndWVsIElzaWRvcm8=?= | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.