How To Write Binary Files to the Browser Using ASP.NET and Visual Basic .NET
This article was previously published under Q307603 On This PageSUMMARY This step-by-step article creates a sample page that
demonstrates how to retrieve binary data from a file and then how to write the
data out to the browser using ASP.NET and Visual Basic .NET. Although this
demonstration uses an Adobe Acrobat (.pdf) file (which Web application
developers commonly use), you can apply this procedure to other binary file
formats. Requirements
Create an ASP.NET Web Application Using Visual Basic .NETThis section demonstrates how to create a new ASP.NET Web Application named BinaryDemo:
Add the PDF File to the ProjectTo set up your project so that you can add and run the code in the Create an ASPX Page section to follow, you must first add an Adobe Acrobat (.pdf) file to your current project. To do this in Visual Studio .NET, follow these steps:
http://www.adobe.com (http://www.adobe.com) Create the ASPX Page
REFERENCES For more information, refer to the following topics in the
.NET Framework Software Development Kit (SDK) documentation:
HttpResponse.WriteFile Method For additional information about how to accomplish this task
using Microsoft Active Server Pages (ASP), click the article number below to
view the article in the Microsoft Knowledge Base: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebHttpResponseClassWriteFileTopic.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebHttpResponseClassWriteFileTopic.asp) HttpResponse Class http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebHttpResponseClassTopic.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebHttpResponseClassTopic.asp) .NET Framework SDK http://www.microsoft.com/downloads/details.aspx?familyid=9B3A2CA6-3647-4070-9F41-A333C6B9181D&displaylang=en (http://www.microsoft.com/downloads/details.aspx?familyid=9B3A2CA6-3647-4070-9F41-A333C6B9181D&displaylang=en) .NET Framework Class Library http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/cpref_start.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/cpref_start.asp) 276488 (http://support.microsoft.com/kb/276488/EN-US/) How To Use the ADODB.Stream Object to Send Binary Files to the Browser through ASP
For more general information about ASP.NET, refer
to the following MSDN newsgroup: microsoft.public.dotnet.framework.aspnet (http://msdn.microsoft.com/newsgroups/default.aspx?query=ASP.NET&dg=&cat=en-us-msdn&lang=en&cr=US&pt=&catlist=774F24A2-F71F-425F-AC2B-DC48AB0DA5C9&dglist=&ptlist=&exp=&sloc=en-us) For more information, see the following books:
Connell, John. Coding Techniques for Microsoft Visual Basic .NET (http://www.microsoft.com/mspress/benelux/books/book18343.htm). Microsoft Press, 2001. Microsoft
provides third-party contact information to help you find technical support.
This contact information may change without notice. Microsoft does not
guarantee the accuracy of this third-party contact
information.Esposito, Dino. Building Web Solutions with ASP.NET and ADO.NET (http://www.microsoft.com/mspress/books/5727.aspx). Microsoft Press, 2001. The third-party products that are discussed in this article are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products. APPLIES TO
| Article Translations
|
Back to the top
