简体   繁体   中英

How To Return PDF From Database In a WCF-Rest Service

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM