Microsoft KB Archive/216521

= Commerce Sale of Soft Goods with BinaryRead/BinaryWrite =

Article ID: 216521

Article Last Modified on 7/15/2004

-

APPLIES TO


 * Microsoft Commerce Server 2.0
 * Microsoft Site Server 3.0 Commerce Edition

-



This article was previously published under Q216521



SYMPTOMS
The example provided in the Commerce 3.0 documentation, which allows for the display or download of files that are not in a virtual directory does not work if there is anything else in the .asp page.



CAUSE
The reason for this is because data that is wrapped in a mime type is all sent to the mime handler. When you put text on the page, the mime type is overridden, causing the browser to handle the data itself rather than passing it to a mime handler.



WORKAROUND
Use the following script in a .asp page by itself for a GIF, JPG, ZIP, or GZ file type:

<%@ LANGUAGE = VBScript %><%

Set oFile = Server.CreateObject("Commerce.AdminFiles")

' use physical path

bFileContents = oFile.ReadFromBinaryFile("c:\temp\postcard.jpg")

Response.ContentType = "image/pjpeg" Response.BinaryWrite bFileContents%>

The images will display in the page and you will be prompted for the download of the zip file. Note, the name of the file that you are prompted to save is not the file that you did a BinaryRead on, rather it is the same as the .asp page without the extensions.



MORE INFORMATION
BinaryWrites of executables do not work even with the contenttype = "octet-stream" because of client configurations that automatically attempt to open the .exe in the browser.

Alternatively the DLL at http://www.microsoft.com/isn/techcenter/downloads/sgDldSvc.exe can be used to have text in the .asp and download zip files. This control was specifically designed and tested with zip files in mind.

Keywords: kbprb KB216521

-

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

© Microsoft Corporation. All rights reserved.