Add a comment. Active Oldest Votes. Improve this answer. Rebecca Talljoe Talljoe Read buffer, 0, buffer. Write buffer, 0, count ; response. It's better to just set up compression of dynamic content in IIS7 config so it happens across the board.
Talljoe - agreed I'd set it up that way as well, I should have been more clear — ljkyser. In asp. Close Response. Write Buffer, 0, FileSize Response. Flush Response. Abdul Saboor Abdul Saboor 3, 2 2 gold badges 30 30 silver badges 25 25 bronze badges. I would like this answer a lot more if it was written in c like the question asks — JSON. OutputStream property, so if you have the PDF file in a stream you can simply copy the data from one stream to the other: CopyStream pdfStream, response.
Community Bot 1 1 1 silver badge. Justin Justin Write buffer, 0, buffer. HttpResponse Class. The third-party products that this article discusses are manufactured by companies that are independent of Microsoft.
Microsoft makes no warranty, implied or otherwise, about the performance or reliability of these products. Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. Write binary files to the browser by using ASP. Please rate your experience Yes No. Any additional feedback? Note Make sure that your page is added to the project at the same level as the.
Response; response. ClearContent ; response. Write reader. End ;. Improve this answer. Don't know which bit of code made it work, but it's finally working : Thanks!
Do you use this with ReportViewer? The downside of specifying a certain amount of bytes is that all those bytes will be written to the stream even if the file isn't as big as that. You could just get the length of the stream and use that number instead when calling reader. ReadBytes — Ciaran Gallagher. ToString CultureInfo. AddHeader "Content-Length", clength ; response.
ClearContent ; inputStream. CopyTo response. OutputStream ; response. Flush ; response. ToInt32 cPosition - length ; outStream. Open filename, FileMode. Extremeswank Extremeswank 5 5 silver badges 7 7 bronze badges. This Snippet did it for me: Response. Clear ; Response. ClearHeaders ; Response. AddHeader "Content-Disposition", "attachment" ; Response. WriteFile filePath ; Response.
Flush ;. Igor Zelaya Igor Zelaya 4, 4 4 gold badges 33 33 silver badges 51 51 bronze badges. I'm not specifing inline on the Disposition I know everyone says not to do it, but I have a Response. Flush ; followed by Response. Jeff Siver Jeff Siver 7, 28 28 silver badges 32 32 bronze badges. BinaryWrite bytes ;. Open path, FileMode. Length]; file. Read buffer, 0, int file.
Split '. Write buffer, 0, buffer. Length ; Response.
0コメント