I have an asp.net 1.1 eCommerce application that has a product page
where the user can select from many different options that affect the
price of the main product. I've implemented this with either a
RadioButtonList or a CheckBoxList that does a postback so I can display
the current price as the user changes options. It works pretty well, but
can do some odd things if the user navigates to the page with the back
button.
I've read up on this quite a bit, and found the following code block to
add to my codebehind to help reduce issues with using the back button:
Response.Buffer = True
Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1)
Response.Expires = 0
Response.CacheControl = "no-cache"
When I use this code on a page that doesn't use auto postbacks, it does
what I want, and that is to display a warning from the browser that the
content is expired.
But on my page that uses all the auto postbacks, the back button just
takes me back to the last postback state and the browser doesn't display
the expired content warning. Can anyone tell me why, or even better how
to make the page not cache even if I use those auto postback controls?
Thanks!
Matt 3 1612
Is this code to expire cache a part of Page_Load ?..
Placing this in page load should expire cache on every post back..
"MattB" wrote: I have an asp.net 1.1 eCommerce application that has a product page where the user can select from many different options that affect the price of the main product. I've implemented this with either a RadioButtonList or a CheckBoxList that does a postback so I can display the current price as the user changes options. It works pretty well, but can do some odd things if the user navigates to the page with the back button. I've read up on this quite a bit, and found the following code block to add to my codebehind to help reduce issues with using the back button:
Response.Buffer = True Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1) Response.Expires = 0 Response.CacheControl = "no-cache"
When I use this code on a page that doesn't use auto postbacks, it does what I want, and that is to display a warning from the browser that the content is expired.
But on my page that uses all the auto postbacks, the back button just takes me back to the last postback state and the browser doesn't display the expired content warning. Can anyone tell me why, or even better how to make the page not cache even if I use those auto postback controls? Thanks!
Matt
Sreejith Ram wrote: Is this code to expire cache a part of Page_Load ?..
Yes it is, and it's not in a If Not IsPostBack block either.
Placing this in page load should expire cache on every post back..
I would have thought the same as you say, but that's not how it seems to
behave.
If I'm debugging and put a breakpoint in that bit of code (first code in
Page_Load), when I use the back button after a postback, my breakpoint
is never hit. So it looks like the Page_Load event isn't firing in these
cases.
Any more ideas?
Thanks for the reply!
Matt
"MattB" wrote:
I have an asp.net 1.1 eCommerce application that has a product page where the user can select from many different options that affect the price of the main product. I've implemented this with either a RadioButtonList or a CheckBoxList that does a postback so I can display the current price as the user changes options. It works pretty well, but can do some odd things if the user navigates to the page with the back button. I've read up on this quite a bit, and found the following code block to add to my codebehind to help reduce issues with using the back button:
Response.Buffer = True Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1) Response.Expires = 0 Response.CacheControl = "no-cache"
When I use this code on a page that doesn't use auto postbacks, it does what I want, and that is to display a warning from the browser that the content is expired.
But on my page that uses all the auto postbacks, the back button just takes me back to the last postback state and the browser doesn't display the expired content warning. Can anyone tell me why, or even better how to make the page not cache even if I use those auto postback controls? Thanks!
Matt
Hello MattB, I have an asp.net 1.1 eCommerce application that has a product page where the user can select from many different options that affect the price of the main product. I've implemented this with either a RadioButtonList or a CheckBoxList that does a postback so I can display the current price as the user changes options. It works pretty well, but can do some odd things if the user navigates to the page with the back button. I've read up on this quite a bit, and found the following code block to add to my codebehind to help reduce issues with using the back button: Response.Buffer = True Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1) Response.Expires = 0 Response.CacheControl = "no-cache"
These are ASP legacy support APIs. The proper way in ASP.NET to control caching
Response.Cache.SetCacheability(HttpCacheability.No Cache);
When I use this code on a page that doesn't use auto postbacks, it does what I want, and that is to display a warning from the browser that the content is expired.
But on my page that uses all the auto postbacks, the back button just takes me back to the last postback state and the browser doesn't display the expired content warning. Can anyone tell me why, or even better how to make the page not cache even if I use those auto postback controls? Thanks!
I strongly recommend against trying to control browser navigation with cache
prevention. This is neither intended by the HTTP spec, nor is there a standard
approach to implement such a feature across all browsers for all cases. If
a back button click is harmful to your application, you should consider implementing
the Redirect-After-Post pattern.
Cheers,
--
Joerg Jooss ne********@joergjooss.de This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: bigbinc |
last post by:
Is there a way to check for the back button? There has got to be a
way with either vbscript/javascript. I could place redirect pages
in there or some creative? any ideas?
|
by: VB Programmer |
last post by:
I have a cmd button on my ASPX form. On my local machine it works
perfectly. After I upload it to the server I click on the button and
NOTHING - doesn't post back to the server.
Any ideas?
...
|
by: Shimon Sim |
last post by:
Hi,
Every time I write ASP.NET application I have the same problem - Back button
on the browser is my enemy. I have to tell client avoid using "Back" button
and if you use it make sure to refresh...
|
by: Robert Megee |
last post by:
I've been able to essentially disable the back button on IE6 by
expiring the cache. I would like to do the same for the browser
that runs on pocketPC. I believe it is IE4. However this technique...
|
by: Tom wilson |
last post by:
I'm developing an application that is a benefits enrolment website.
The benefits can be of any type in any order as stored in a SQL
server. On each page is a Back and Next button. At a certain...
|
by: Tony Doyle |
last post by:
All,
I have a web form with 3 embedded panels, all working fine.
However, I have now added a Checkbox where autopostback=true, and only the
ascx pages on my page appear, none of the panels /...
|
by: Sridhar |
last post by:
Hi,
I have a question regarding the Page_Load method and Back Button of
Internet explorer. I have created a webform. In that webform I have several
Text Boxes. Also I have two buttons. When I...
|
by: mrboyer79 |
last post by:
hello all,
i'm having an issue where the back button i created (not the browser back) is causing me to lose data. allow me to explain:
i have three pages. page one is a short form where the user...
|
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= |
last post by:
I the page knows there was a cross post back. but i can not find the control.
(asp.net 3.5)
calling page has a master
calling control:
<asp:Button ID="btnSendAlert" runat="server" Text="Go"...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |