I have an action that displays a pdf
public ActionResult MyPdf()
{
var response = pdfService.MyPdf(new PdfRequest() { SiteId = siteSession.ActiveSiteId });
return File(response.Pdf, "application/pdf");
}
The service opens a PDF, fills out the form using data from the database, and then passes back a container class. response.Pdf
is a byte[]
.
What I want to do is set the page title used by the browser when the PDF is opened. Currently, File(response.Pdf, "application/pdf");
will allow my browser (chrome) to display the pdf.
If I change it to File(response.Pdf, "application/pdf", "My PDF File Name");
, the pdf is not displayed but is automatically downloaded.
My action has no View defined. How can I show the PDF in the browser without forcing the download and set the page title from my action method?
File
your own type or is it included in the framework? – GuruleFileContentResult
– Lawrenson