I want to open a report in a new tab which is a pdf file. I want to do it without saving this file in my computer. I am using asp.net MVC 5. On the given code, when I click the Export Report button it just download the pdf. But I want to view it first in a new tab then download.Here is my code:
Controller:
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");
}
View:
<div>
<a href="@Url.Action("ExportLogReport","SaveLogMaster")" target="_blank">Export Report</a>
</div>