file download with WriteFile method gives an empty file ?

G

Guest

Hi.

I've got this code in my download page Page_load() method, but all I got in
the end is an empty file on client side... any clue ?

string filename="testfile.pdf";
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=\"" +
filename + "\"");
Response.Flush();
Response.WriteFile("c:\\temp\\testfile.pdf");
 
G

Guest

Eric,
Besides the obvious (e.g., ensuring the file to send is where expected and
isn't empty), try taking out the "Response.Flush" line, and add
"Response.End()" at the end after WriteFile.
Peter
 

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

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top