Solved

force a page load on browser back button in c#

Posted on 2012-03-10
3
656 Views
Last Modified: 2012-03-11
I have a webpage http://www.practicelifeintheuktest.co.uk/life-in-the-uk-free-sample-test.aspx  for a quiz test. When user finishes the test and goes to result page and clicks on the browser back button. The page_load event does not fire and session variables which are set in page load are not set and the page does not behave correctly. How can we force page load when user clicks the back button. I have tried a couple of possible solutions like setting the no cache properties but it does not seem to work on this case.

Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.AddDays( - 1);
Response.Expires = 0;
Response.CacheControl = "no-cache";

and

Response.Cache.SetCacheability(HttpCacheability.NoCache);
0
Comment
Question by:mmalik15
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
Comment Utility
Unless you are using javascript/AJAX to load the page, clicking on 'Back' does not contact the server, it just displays from the history cache in the browser which is not the same as checking 'cache' when a new link is clicked.  All the things you listed above are only run on the server and never seen when 'Back' is clicked.
0
 

Author Comment

by:mmalik15
Comment Utility
thanks for the comment but any suggestion how to handle the back button in this case
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
You can't 'handle' the back button from the server because the server isn't involved.  Only if you do your page load with javascript / AJAX can you reload anything from the server.

What happens if you refresh the page after clicking on 'Back'?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now