I'm doing a WCF-REST service using C#, which connects with a database in SQL Server to return several tables. Now, I need that my service returns a PDF File, which is stored at the table, in a varbinary(MAX) field. I'm doing some research but I can't found something like I need. How can I implement the service and class to return a PDF File? Thanks
Asked
Active
Viewed 1,885 times
1
-
Duplicate http://stackoverflow.com/questions/16027117/how-to-return-pdf-binary-data-from-a-database-in-a-wcf http://stackoverflow.com/questions/6819639/pdf-using-wcf-restful-services – Ralf de Kleine Apr 16 '13 at 19:51
1 Answers
1
1) write a method that returns a Stream
(For ex, a MemoryStream holding your pdf file).
before returning from that method
2) Set application/pdf
to WebOperationContext.Current.OutgoingResponse.ContentType
3) set the length to WebOperationContext.Current.OutgoingResponse.ContentLength
Then it should work.

I4V
- 34,891
- 6
- 67
- 79
-
-
@anhtv13 `WebOperationContext.Current.OutgoingResponse.Headers.Add("Content-Disposition: attachment; filename=\"" + filename + "\"");` – Rory Feb 15 '18 at 13:42