Solved

force a page load on browser back button in c#

Posted on 2012-03-10
3
697 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 37705398
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
ID: 37705459
thanks for the comment but any suggestion how to handle the back button in this case
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 37705481
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!

763 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