I have a WCF-REST service that returns data in JSON format, that reads from a database in SQLSERVER... To return simple data, I don't have any problem.
Now, I want to return,a PDF file, that is at the database in varbinary(max) field.
What is the correct way to return the PDF data in a WCF Rest Service?
[EDITED]
This is how It was suggested. This is the class:
[WebGet(UriTemplate = "/documents/{id}")]
public ActionResult GetDocument(int id)
{
using (var context = new CorrespondenceDataContext())
{
var item = context.DocumentsPDFs.Find(id);
return File(item.Document, "application/pdf", "Document-" + id);
}
}
Now I already did it exactly like the suggestion, but I guess it's not compatible with my project (I'm a little bit new on this)...
First error: The type or namespace name "ActionResult" could not to be found
Second error: System.Data.Linq.Table does not contain a definition for Find
Third error: System.IO.File is a type but is used like a variable
I tried to add System.Web.MVC, but it does not appears. My project is WCF Service Application...