Back Button and code execution

J

John

Hi,

I have a web form accounting app. In certain instances it
causes trouble if the user clicks the Back button. I've
read several posts that indicate that it is not
recommended (or even possible) to try to disable the Back
button. So, what I did was save a session variable with
the name of the current webform and then check this
session variable on page load to make sure the user was
not coming from a page that was not acceptable.

This works when I navigate to the page by typing in a URL
but is seems like when I click the Back button to go to a
page I should not go back to, the code behind is not
executed. Is there some way to force this to always be
executed?

Thanks,
John Ritchie
 
M

Marina

The problem is that the browser loads a cached version of the page - so it
doesn't go to the server at all.

You can try to set the expiration of the page to expire immediately, but I'm
not sure how well that works.
 
Y

Yan-Hong Huang[MSFT]

Hello John,

Marina is right. Preventing it from caching may resolve this issue.

Besides, In order to prohibit a page from caching, you could also place following Meta tag in the head of the html.
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

Hope that helps.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!Content-Class: urn:content-classes:message
!From: "John" <[email protected]>
!Sender: "John" <[email protected]>
!Subject: Back Button and code execution
!Date: Wed, 30 Jul 2003 08:32:27 -0700
!Lines: 19
!Message-ID: <[email protected]>
!MIME-Version: 1.0
!Content-Type: text/plain;
! charset="iso-8859-1"
!Content-Transfer-Encoding: 7bit
!X-Newsreader: Microsoft CDO for Windows 2000
!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!Thread-Index: AcNWr8hsqj5nJmscRzCveBt3X2bLyg==
!Newsgroups: microsoft.public.dotnet.framework.aspnet
!Path: cpmsftngxa06.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:163398
!NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
!
!Hi,
!
!I have a web form accounting app. In certain instances it
!causes trouble if the user clicks the Back button. I've
!read several posts that indicate that it is not
!recommended (or even possible) to try to disable the Back
!button. So, what I did was save a session variable with
!the name of the current webform and then check this
!session variable on page load to make sure the user was
!not coming from a page that was not acceptable.
!
!This works when I navigate to the page by typing in a URL
!but is seems like when I click the Back button to go to a
!page I should not go back to, the code behind is not
!executed. Is there some way to force this to always be
!executed?
!
!Thanks,
!John Ritchie
!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top