我想在一个新的选项卡中打开一个报告,该选项卡是pdf文件。我想要执行此操作而不将其保存在计算机中。我正在使用asp.net MVC5。在给定的代码上,当我单击“导出报告”按钮时,它只是下载pdf。但是我想先在一个新标签页中查看它,然后下载。这是我的代码:
控制器:
public ActionResult ExportLogReport()
{
List<LogDetails> allCustomer = new List<LogDetails>();
allCustomer = aSaveLogMasterManager.GetAllLogDetails();
ReportDocument rd = new ReportDocument();
rd.Load(Path.Combine(Server.MapPath("~/Reports"), "CrystalReport1.rpt"));
rd.SetDataSource(allCustomer);
Response.Buffer = false;
Response.ClearContent();
Response.ClearHeaders();
Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/pdf", "LogDetailsList.pdf");
}
查看:
<div>
<a href="@Url.Action("ExportLogReport","SaveLogMaster")" target="_blank">Export Report</a>
</div>