retrieving PDF file with ServerXMLHTTP object

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Brian Barnett (bwbarnett_at_hotmail.com)
Date: 02/14/04


Date: Sat, 14 Feb 2004 15:46:07 -0800


(Using the previous ASP technology, not ASP.NET. Sorry if this is the wrong newsgroup. If so, please point me in the right direction.)

I've just about got it working, except the browser is displaying binary data instead of using Adobe Acrobat to display the PDF.

Here is the source code I'm using:

Response.Buffer = False
Response.ContentType = "application/pdf"
set httpReq = Server.CreateObject("Msxml2.ServerXMLHTTP")
httpReq.open "GET", PDFFileURL, false
httpReq.send ""
if (httpReq.status <> 200) then
  Response.Write("Error")
else
  Response.BinaryWrite httpReq.responseBody
end if
set httpReq = nothing

If I type in the URL of the pdf file directly into the address bar of the browser, it opens it fine. I just can't get it to work using Response.BinaryWrite.

System Info:
W2K Pro
IIS 5.0
IE 6.0

I'd appreciate any suggestions.

Thanks,
Brian Barnett