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.