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!
Fixed it via this answer: Returning a file to View/Download in ASP.NET MVC
Had to append a content disposition header, and set the “Inline” value of the content disposition to true.