FIX: XMLHTTP.Open Method Fails When the Password Contains a Number Sign (#) (290893)



The information in this article applies to:

  • Microsoft XML 2.6
  • Microsoft XML 3.0
  • Microsoft XML 3.0 SP1

This article was previously published under Q290893

SYMPTOMS

When you try to open a connection by using a XMLHTTP object with a username and password, and the password contains a number sign (#), a run-time error occurs on the Send method and you receive the following error message:
Error number:800401e4
Error Description: Invalid Syntax
NOTE: This does not occur with MSXML versions 1.0, 2.0, or 2.5.

CAUSE

The XML processes (instead of escapes) the number sign (#).

RESOLUTION

To work around this problem, use earlier versions of the XMLHTTP object to make the requests.

STATUS

This problem was corrected in MSXML 4.0.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Make sure that you have a user account with a password set up on a computer that is running Microsoft Windows NT or Microsoft Windows 2000.
  2. Paste the following code into Notepad and save it as Clienthttp.asp.
    <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
    <!--
    
    function XMLHTTPButton_onclick() {
    	var xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");
    	xmlhttp.Open("GET","http://localhost/Receiver.asp",false, "TestUser", "Test#User");
    	xmlhttp.Send();
    	alert(xmlhttp.responseXML.xml);
    }
    
    //-->
    </SCRIPT>
    
    <INPUT type="button" value="Submit XMLHTTP" id=XMLHTTPButton name=XMLHTTPButton LANGUAGE=javascript onclick="return XMLHTTPButton_onclick()">
    					
  3. In the above code, change TestUser and Test#User to reflect your user account's user name and password, respectively.
  4. Paste the following code into Notepad and save it as Receiver.asp.
    <%@language=vbscript%>
    <%
    	Response.ContentType = "text/xml"
    	response.write "<ReturnValue>1</ReturnValue>"
    %>
  5. In the Internet Information Services Manager, right-click Receiver.asp and click Properties. Click File Security and edit the anonymous user authenication so that only Basic Authentication is selected. Click OK to save the changes.
  6. Make sure that the page is set for Basic authentication and that the user account that you have chosen can browse to Receiver.asp.
  7. Run Clienthttp.asp.
  8. Click the button that you created.

REFERENCES

For more information about MSXML, see the following Microsoft Developer Network (MSDN) Web site:

Modification Type:MajorLast Reviewed:10/16/2002
Keywords:kbBug kbDSupport kbMSXML400fix KB290893 kbAudDeveloper