PDF not downloaded in IE 6, 7, but Firefox works OK.

B

Brent

I'm trying to stream files back to the user's browser. Text and JPG
files seem to work fine, but I get nothing -- actually, the missing
photo icon with the red "X" -- when streaming PDF to Internet Explorer
6.x and 7 (beta). I'm hoping for some pointers with this code snippet:

===============================

path = @"c:\pathIsHere\";
filename = "filename.pdf";
Response.ClearContent();
Response.ContentType = "Application/pdf";
long StartPos = 0, FileSize;
FileInfo fi = new FileInfo(path + filename);
FileSize = fi.Length;
Response.AddHeader("Content-Disposition","Filename="+filename);
Response.WriteFile(path + filename, StartPos, FileSize);
Response.End();

===============================

The code works fine in Firefox, and for some other file types in most
browsers. But it kills PDF.

Thanks for any help!

--Brent
 
J

Joerg Jooss

Thus wrote Brent ""b b i g l e r y a h o o . c o m,
I'm trying to stream files back to the user's browser. Text and JPG
files seem to work fine, but I get nothing -- actually, the missing
photo icon with the red "X" -- when streaming PDF to Internet Explorer
6.x and 7 (beta). I'm hoping for some pointers with this code snippet:

===============================

path = @"c:\pathIsHere\";
filename = "filename.pdf";
Response.ClearContent();
Response.ContentType = "Application/pdf";
long StartPos = 0, FileSize;
FileInfo fi = new FileInfo(path + filename);
FileSize = fi.Length;
Response.AddHeader("Content-Disposition","Filename="+filename);
Response.WriteFile(path + filename, StartPos, FileSize);
Response.End();
===============================

The code works fine in Firefox, and for some other file types in most
browsers. But it kills PDF.

Try using TransmitFile() instead of WriteFile().

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top