Hi,
I want to redirect to another page after response.end()?
this is my code pls help me?
LocalReport rep = new LocalReport();
rep.ReportPath = "emrReports/prescription.rdlc";
ReportDataSource dsPrescription = new ReportDataSource("dsPrescription1", objRepMedicationDAO.getPrescription(objrepMedicationDTO).Tables[0]);
rep.DataSources.Clear();
rep.DataSources.Add(dsPrescription);
//objPrintReport.Export(rep);
//rep.Refresh();
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
byte[] bytes = rep.Render(
"PDF", null, out mimeType, out encoding,
out extension,
out streamids, out warnings);
// FileStream fs = new FileStream(System.Web.Hosting.HostingEnvironment.MapPath("~/Pdf/" + Session["PatientId"].ToString() + ".pdf"), FileMode.OpenOrCreate, FileAccess.Write);
FileStream fs = new FileStream(Server.MapPath(@"~\test.pdf"), FileMode.Create);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
string path = Server.MapPath(@"~\test.pdf");
// System.Diagnostics.Process.Start(path);
System.IO.FileInfo file = new System.IO.FileInfo(path); //-- if the file exists on the server
if (file.Exists) //set appropriate headers
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/pdf";
Response.WriteFile(file.FullName);
Response.End();
Response.redirect("download.aspx");
}
else
{
// if file does not exist
Response.Write("This file does not exist.");
}
this will not working...if comment response.end(), redirect to page but pdf not opened..pls suggest me