User1740231301 posted
ReportDocument rptDoc = new ReportDocument();
rptDoc.Load(Server.MapPath("ETR0040.rpt"));
// Fetch report parameters to retrieve report data.
...
// Retrieve report data.
DataSet dsResult = DBGateway.ExecuteCommand('command');
rptDoc.SetDataSource(dsResult);
// Report parameters - to be passed if there are any parameters which should be passed to report.
rptDoc.SetParameterValue("CustomerCode", customerCode);
DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
string targetFileName = Request.PhysicalApplicationPath + "Reports\\TempReports\\" + (new Random()).Next() + ".pdf";
rptDoc.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
rptDoc.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
diskOpts.DiskFileName = targetFileName;
rptDoc.ExportOptions.DestinationOptions = diskOpts;
// Export report ... Server-Side.
rptDoc.Export();
FileInfo file = new FileInfo(targetFileName);
Response.ClearContent();
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/pdf";
Response.TransmitFile(file.FullName);
set your name in targetFileName