BUG: Opening a Stream to a URL Produces "Accessing Data Across Domains" Warning Message (260260)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 5
  • Microsoft Internet Explorer (Programming) 5.01
  • Microsoft Internet Explorer (Programming) 5.01 SP1
  • Microsoft Internet Explorer (Programming) 5.5

This article was previously published under Q260260

SYMPTOMS

If safety settings on the browser prohibit accessing data on another domain, and the Open method of a stream object is called from a client's browser, then the following warning message is reported:
"This page is accessing data on another domain."
The error occurs even if the source for the method references a URL on the same domain from which the page was loaded.

RESOLUTION

On the Tools menu, select Internet Options, and then select the Security settings dialog box to adjust the client browser to enable "Access data sources across domains" for the proper Internet zone (Internet, intranet, and so forth).

STATUS

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

MORE INFORMATION

Steps to Reproduce Behavior

To reproduce this problem, insert the following code into a new ASP page and save the page on a Web server:
<HTML>
<HEAD>
<TITLE>Repro Page for Microsoft Knowledge Base Article Q260260</TITLE>
<SCRIPT language="VBScript">
	Sub Send()
		' Upload the contents of the file to the server
		
		const adTypeBinary = 1
		
		const adModeWrite = 2
		const adModeReadWrite = 3
		
		const adCreateOverwrite = &H4000000
		
		dim objStream, objRecord
		dim strUrl, strFile

		strUrl = "http://<servername>/upload/"
		strFile = "NewFile.txt"

		set objRecord = CreateObject("ADODB.Record")
		set objStream = CreateObject("ADODB.Stream")
		
		' Open a new record object with a number of flags set
		objRecord.Open strUrl + strFile, "", adModeReadWrite, adCreateOverwrite

		objStream.Type = adTypeBinary
		
		' The following line generates the error if safety settings on the
		' machine prohibit accessing data on another domain.
		objStream.Open "URL=" + strUrl + strFile, adModeWrite
		objStream.LoadFromFile document.frmFile.flFileName.value

		objStream.Close
		objRecord.Close 
		set objStream = nothing
		set objRecord = nothing
		
		' Post the form to display the image from the server,
		' demonstrating that it was uploaded successfully.
		document.frmFile.submit 
	End Sub
</SCRIPT>
</HEAD>
<BODY>
	<H2>Repro code for Microsoft Knowledge Base Article Q260260</H2>
	<FORM id="frmFile" name="frmFile" action="http://jburchel/upload/NewFile.txt" method="GET">
		<B>Select a text file and click submit.  The script on this page will copy it to the server.<BR>
		The script will then submit this form, viewing the file that was created on the server.</B>
		<BR><BR>
		File to upload: <INPUT type="file" id="flFileName" name="flFileName">
		<BR><BR>
		<INPUT type="button" id="btnSubmit"	name="btnSubmit" value="Submit File" onclick="Send()">
	</FORM>
</BODY>
</HTML>
				
NOTE: If you do not follow the instructions in the "Resolution" section earlier in this article, this page fails.

Modification Type:MajorLast Reviewed:5/8/2003
Keywords:kbbug kbpending KB260260