473,698 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Back button issues

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.Expire sAbsolute = DateTime.Now.Ad dSeconds(-1)
Response.Expire s = 0
Response.CacheC ontrol = "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
Jan 20 '06 #1
3 1622
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.Expire sAbsolute = DateTime.Now.Ad dSeconds(-1)
Response.Expire s = 0
Response.CacheC ontrol = "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

Jan 20 '06 #2
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
RadioButtonLi st 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.Expire sAbsolute = DateTime.Now.Ad dSeconds(-1)
Response.Expire s = 0
Response.CacheC ontrol = "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

Jan 20 '06 #3
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.Expire sAbsolute = DateTime.Now.Ad dSeconds(-1)
Response.Expire s = 0
Response.CacheC ontrol = "no-cache"
These are ASP legacy support APIs. The proper way in ASP.NET to control caching

Response.Cache. SetCacheability (HttpCacheabili ty.NoCache);
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********@joer gjooss.de
Jan 21 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
4942
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?
4
2597
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? I created a new sample test.aspx form with 1 button and this one posted back ok. Thanks.
8
6131
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 the page to latest information. I decided to pay information to application on the web and I see that some sites don't have those issues. Like I used some forum site that uses PERL (files with ext. pl) and Back button from browser gets new...
3
1348
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 doesn't seem to work. Anyone know how I might try to keep the back button from showing previous pages of this application? thanks, Robert Megee
5
2393
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 point in the initialization of the app, I determine a navigational structure; what benefit is first, second, etc., therefore, which page to display first, second and so on. In session memory I store an array of page URL's and a single value...
6
1780
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 / tables do. It just doesnt make sense, looking at the source of the page in view i see <input type="hidden" name="__VIEWSTATE" (plus a lot of text)
7
2485
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 click on button1, it populates the text boxes with person1 details. When I click on button2, it populates the text box with person2 details and redirects to webform2. In webform2 if I click on Back Button of Internet Explorer it should display...
1
3048
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 enters in their name (first, mi, last) and a number and there's a y/n radio button. the user then clicks submit and is taken to page two. page two is a review of the data provided on page one. if all is well the user clicks submit and is taken to...
8
2034
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" onclick="btnSendAlert_Click" PostBackUrl="ItemUpLoadAdmin.aspx" CommandArgument="5" />
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8610
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.