Skip to content Skip to sidebar Skip to footer

How To Return PDF/Binary Data From A Database In A WCF

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

Solution 1:

    [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);
        }
    }

Post a Comment for "How To Return PDF/Binary Data From A Database In A WCF"