开发者

Set Page Title for a PDF inside the Action

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.开发者_如何学JAVAPdf 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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜