Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Populating the data attribute of an object tag in Chrome with an ASP.NET MVC action that serves a PDF file result

I have a FileResult action that returns a PDF. I want to embed this PDF in an object tag. When I insert the action into the data attribute of the object tag, like below, no PDF is retrieved or shown in Chrome. (The PDF is shown in Firefox with the Adobe plugin - I don't care about IE.)

<object data="@Url.Action("GetPDF", "PDFCreation", new {id= Model.DocumentId})" type="application/pdf"></object>

It all works otherwise - the object tag works with a direct link to a PDF on the file system (e.g., data="~/Content/test.pdf"), and the Action above, if hard-pasted into the location bar, downloads the PDF.

Any thoughts? Thank you!

like image 518
Gabe Avatar asked Oct 05 '22 15:10

Gabe


1 Answers

I managed to get IE to display a Pdf that was thrown back using a FileContentResult and the following object tag

<object>
    <embed src="@Url.Action("GetPDF", "PDFCreation", new {id= Model.DocumentId})" type="application/pdf"></embed>
</object>

Might be worth a try

like image 55
Slicksim Avatar answered Oct 10 '22 13:10

Slicksim