Posted 3 June 2025, 11:00 am EST
Hi everyone,
I’m having an issue with using the C1 MVC PdfViewer in an ASP.NET MVC 4.8 application and I hope someone here can help me out.
My goal is to display a PDF document in the PdfViewer that is delivered by an API controller. The PDF is provided via an API that returns the PDF as a byte array.
Current Setup:
*I’ve successfully embedded the C1 MVC PdfViewer in my Razor View, and it’s visible.
*I can access the PdfViewer via JavaScript using wijmo.viewer.pdfViewer.getControl(‘#pdfViewerPlaceholder’), and this works as expected.
*There are two relevant properties, serviceUrl and filePath, that I am setting, but so far the PDF doesn’t show up in the viewer.
My API Endpoint:
I have an API controller that returns the PDF by ID. The endpoint looks something like this:
'api/Files/{id}'
The return in the controller looks something like this:
var msg =new HttpResponseMessage()
{
Content = new StreamContent(pdfBytes)
}
msg...ContentType = new ....("application/pdf");
msg...ContentDisposition = new ...("attachment")
msg...ContentDisposition.FileName = "testID*.pdf"
The Problem:
Although the endpoint returns the PDF correctly as application/pdf, the PDF is not being displayed in the PdfViewer.
My Question:
How should I properly set the serviceUrl and filePath so that the PDF is displayed in the PdfViewer? Or is there another configuration I need to consider?
Thanks in advance!