We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 62,896 times

Contents

Related Categories

Send Binary Data from ASP - Introduction

LACanadian

Introduction

One of the more common tasks that we've performed is to send a existing document to the browser. For our client base, the most common document types include Adobe Acrobat (.pdf), Microsoft Word (.doc) and PKZip (.zip). Innately, it is not hard to get these files to the client. Simply using a Response.Redirect to the path for the document works. However, if the documents are kept in a location other than in the hierarchy underneath the web root, there are security considerations that need to be addressed. I don't know about you, but I'd rather look for alternates rather than knowingly expose my site to security holes. As well, if you client has associated the type of the downloaded file with an application on their computer, the document will be automatically opened. In many cases, I would rather have the user save the document in their field system.

Fortunately, we discovered a relatively straightforward option that was open to us. With just a few lines of code, we can not only push binary data directly from ASP, but also force the user to save the document onto their hard drive.

I am the owner of a small application development consulting company that specialized in the design and implementation of Internet-based applications. While there are others who can make a web site look good, our expertise is in making the site function. This includes infrastructure design, database design and administration, software development and deployment. For the most part, we utilize Microsoft-based languages and tools. And we are skilled enough to have generated two patent applications for our clients.

Comments

  • Posted by ckchan on 12 Feb 2006

    Hi, thanks for the code. i tested it in my ASP site.

    i find however the code works for pdf files of around <80K size. Once the pdf files goes past 80K, the code bombs. All i see in the req...

  • RE:Opening PDF in Windows 2000

    Posted by victormois on 10 Oct 2005

    gjohnson, I can think of two things.
    1. check XP/IE security settings
    2. Reinstall Adobe Reader.

  • Opening PDF in Windows 2000

    Posted by gjohnson on 08 Oct 2005

    I am having the exact same problem except my code works on a Windows XP computer but does not work in Windows 2000. In XP, acrobat opens in my web application and the pdf displays as it should. In 2...

  • pdf content into an array

    Posted by rocko_hunk on 06 Oct 2005

    hi below is the code u sent

    Response.Clear();
    Response.Buffer = true;
    Response.ContentType = "application/pdf";
    Response.BinaryWrite(tPDF);
    Response.End();

    I know very well that I n...

  • Posted by victormois on 05 Oct 2005

    rocko_hunk, sure it will throw an error on this line: Response.BinaryWrite(tFileName)
    Because, tFileName is a string and you need to pass to Response.BinaryWrite method a binary array with proper PDF...