Microsoft KB Archive/216522

= Commerce Sale of Soft Goods with BinaryRead BinaryWrite =

Article ID: 216522

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Site Server 3.0 Commerce Edition

-



This article was previously published under Q216522



SUMMARY
In the Site Server 3.0, Commerce Edition documentation, the example provided 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. This is because the data that is wrapped in a mime type is all sent to the mime handler. When text is put on the page, it overrides the mime type so that the browser handles the data itself, rather than passing it to a mime handler. 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 that the name of the file that you are prompted to save does not have the same name as the file that you did a BinaryRead of; it has the same name as the .asp page, but without the extensions.



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

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

Keywords: kbinfo KB216522

-

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

© Microsoft Corporation. All rights reserved.