无法将 PDF 嵌入到 ASP.NET MVC 视图中

Unable to embed PDF into the ASP.NET MVC view

我有一个 ASP.NET MVC 应用程序,它 returns 一个 PDF 流。我正在尝试将该流嵌入到视图中。我在控制器中有这个动作

[AuthorizeResultVisible]
public ActionResult GetPDFStream(int reportId)
{
        byte[] pdfByteStream = GetReportBytes(reportId);
        Response.Clear();
        Response.AddHeader("Content-Disposition","inline; filename=sample.pdf");
        Response.AddHeader("Content-Type","application/pdf");
        Response.ClearHeaders();
        Response.AddHeader("Content-Length", pdfByteStream.Length.ToString());

        return new FileContentResult(pdfByteStream, "application/pdf");
}

在我看来我正在尝试两者,对象标签 and/or iframe 标签

<object data="'<%= Url.Action("GetPDFStream", "ResultActions", new {reportId = Model.reportId }) %>" #zoom=150′ width = "100%" height="525" id="iFramePdf" frameBorder="1" type="application/pdf"/>
<iframe src="'<%= Url.Action("GetPDFStream", "ResultActions", new {reportId = Model.reportId }) %>"/>

但是,无论我做什么,嵌入的 PDF 都不显示。相反,弹出错误消息说

HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

但是,当我进入源时,我能够检索 link 并确认 link 有效。一旦我将 link 粘贴到浏览器中,它就会显示 PDF,但最初没有显示 PDF

有人可以帮忙吗

提前致谢

通过添加 Request.Url.GetLeftPart(UriPartial.Authority)

找到解决方案
<iframe src="**<%= Request.Url.GetLeftPart(UriPartial.Authority)** + Url.Action("GetPDFStream", "ResultActions", new {reportId = Model.reportId }) %>" #zoom=150′ width = "100%" height="525" id="iFramePdf" frameBorder="1" type="application/pdf"/>