Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
How To Read and Display Binary Data in ASP
Article ID: 193998 - View products that this article applies to.
This article was previously published under Q193998
This article shows how to read and display binary data using Active Server Pages.
Many developers appreciate the ease of using the Scripting.FileSystemObject to open an ASCII file and then display its contents in Microsoft Word or Microsoft Excel from within Internet Explorer. In its current inception, ASP does not directly provide any comparable objects to read files that contain binary data such as an Excel worksheet with macros, an Adobe Acrobat (.pdf) file, a .gif image, or any other files that contain binary data. However, an ASP developer can write a custom business object or component that adds this functionality.
Part I provides the ASP code that receives and then displays the binary file using an appropriate MIME type, and Part II shows how to create the Visual Basic 5.0 (or later) ActiveX DLL component that extends the capability of ASP to read binary data.
Part I: ASP Sample That Opens an Excel Worksheet Containing Macros
NOTE: For Acrobat files, change the MIME type by using Response.ContentType = "application/pdf". For a .gif image, use Response.ContentType = "image/gif".
Part II: The Visual Basic 5.0 ActiveX DLL (MyObject.BinRead)To create the component that performs the binary read, perform the following steps:
To incorporate the file created in Part I into another ASP page that has text or other formatting, use a server side include statement.
Article ID: 193998 - Last Review: March 16, 2005 - Revision: 2.5