Microsoft KB Archive/265843

= BUG: Pressing ENTER on the URL Bar Does Not Reload a Posted Page =

Article ID: 265843

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.0
 * Microsoft Active Server Pages 4.0

-



This article was previously published under Q265843



SYMPTOMS
Many Web sites use re-entrant ASP pages to implement a method known as &quot;post-back&quot; to process input that is submitted by users in HTML forms. The post-back method allows a form to be posted back to the same page that displays it. An ASP that implements this method to process form input is commonly known as a re-entrant ASP page. A HTTP_GET is invoked to initially display the form when the user enters the URL to the .asp or clicks on a hyperlink that points to it. When the form is filled out and submitted, the contents of the form elements are posted back to the same page by invoking a HTTP_POST. The ASP usually processes the input posted and generates a response HTML page as an acknowledgement to the user.

A convenient aspect of this method is that the URL displayed in the browser's address bar does not change during the entire process of displaying the input form, accepting user input, posting/processing the input, and displaying a response HTML page.

However, pressing the ENTER key on the browser's URL address bar when the POST version of the ASP page is displayed does not result in a reload on the GET version of the page that displays the blank input. Re-entering the URL in the address bar and pressing ENTER also results in a reload of the POST version of the page.



RESOLUTION
There are several workarounds for this problem:
 * Mouse-click the BACK button in the browser when the POSTED version of the page is displayed to issue a HTTP_GET that displays the empty form to accept fresh user input.
 * Include a hyperlink in the Response page generated by the POST operation that points back to the URL of the page. Click this hyperlink in the browser when the POST version of the page is displayed to reload the GET version and display the blank input form.
 * If the form was initially displayed by keying in the URL to access it, then selecting the URL from the drop-down portion of the browser's address bar results in a reload of the GET version of the page. NOTE: This needs to be done only once. Directly pushing ENTER on the URL address bar of the POSTED page for every subsequent POST has been noticed to initiate a reload of the GET version of the page.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Open a new text file in Notepad. Save the file as selfpost.asp in a virtual folder on your Internet Information Server (IIS).  Copy and paste the following code in selfpost.asp: <%@Language=VBScript%>

  <% Response.write &quot;Request Method : &quot; & Request.ServerVariables(&quot;REQUEST_METHOD&quot;) & &quot;&quot; If Trim(Request.Form(&quot;txtName&quot;)) <> &quot;&quot; Then Response.Write &quot;You Entered the Following Details : &quot; & &quot;&quot; Response.Write &quot;Name : &quot; & Request.Form(&quot;txtName&quot;) & &quot;<BR>&quot; Response.Write &quot;Email : &quot; & Request.Form(&quot;txtEmail&quot;) & &quot;<BR>&quot; Response.Write &quot;<HR>&quot; Response.Write &quot;<BR>&quot; Response.End End If %>

<FORM METHOD=&quot;POST&quot; ACTION=&quot;selfpost.asp&quot;>

Enter Your Name : <BR> <INPUT TYPE=text NAME=txtName> <BR><BR>

Enter your E-mail address : <BR> <INPUT TYPE=text NAME=txtEmail> <BR><BR>

<INPUT TYPE=submit Value=&quot;Submit&quot;>

</FORM>

</BODY> </HTML> </li> Save the file again. Open the ASP in Internet Explorer 5 by typing in the URL to access it in the address bar. Note that a simple input form with fields to key in a name and an e-mail address is displayed.</li> Enter some input into the two fields, and then click Submit. The form contents is now POSTED back to the same page that generates a Response page acknowledging the input that is submitted.

Note that the URL that is displayed in the address bar does not change as the form is being posted back to the same page.</li> Press ENTER after placing the cursor in the Address bar. Note that the GET version of the page that displays the blank form is not reloaded.</li></ol>

If the initial form was displayed by keying in the URL to access it as opposed to clicking a hyperlink that points to it, the URL entered is displayed in the drop-down portion of the address bar. Selecting this URL from the drop-down portion results in a re-load of the GET version of the page that displays the blank input form. Re-entering the URL in the address bar and pressing ENTER does not result in the GET version being reloaded.

Key in some input and resubmit the form to display the POST version of page. Pressing ENTER on the address bar this time results in the reload of the GET version as opposed to the first instance when the POSTED page was reloaded. If you navigated to the blank form initially by following a hyperlink, the URL is not listed in the drop-down portion of the address bar. In that case, you are not able to reproduce this specific behavior until you close down the browser and revisit the page by keying in its URL in the address bar.

A simple workaround as listed in the &quot;Resolution&quot; section of this article is to include a hyperlink that points to the URL of the re-entrant ASP page in the Response written out by the POST. Clicking the hyperlink when the posted page is displayed results in a reload of the GET version of the page. Copy and paste the following Response.End statement in the preceding code into the selfpost.asp file, and then test the modified page to evaluate the result: Response.Write &quot;<A href=selfpost.asp>Return to Form</A>&quot;

Additional query words: selfpost

Keywords: kbbug kbpending KB265843

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.