I have an aspx (say 1.aspx) page from where first I am downloading a pdf file and then I want to redirect to some 2.aspx page. The code is this:
protected void buttSubmit_Click(object sender, EventArgs e)//Submit button to generate PDF
{
if (intInvoID > 0)
{
UpdateInvoice();
}
else
{
SaveInvoice();
}
GenearatePDf(strheader, htrFooter, strContact, strExihibition, strPaymentDetails, strNotes);
Response.AddHeader("Refresh", "12;URL=~/expo_crm/invoice/View_Invoices.aspx");
}
}
Here,I am not able to redirect to View_Invoices.aspx. I tried using Response.header.But its not working.
private void GenearatePDf(string strheader, string strFooter, string strContact, string strExihibition, string strPaymentDetails, string strNotes)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Invoice_" + txtCompanyName.Text.Trim() + ".pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
StringReader srHtmlText = new StringReader(sbHtmlText.ToString());
Document pdfDocument = new Document(PageSize.A4, 40f, 40f, 15f, 2f);
iTextSharp.text.html.simpleparser.HTMLWorker htmlparser = new iTextSharp.text.html.simpleparser.HTMLWorker(pdfDocument);
PdfWriter pdfDoc1 = PdfWriter.GetInstance(pdfDocument, Response.OutputStream);
var page = new ITextEvents();
page.email = txtExpogrEmail.Text.Trim();
pdfDoc1.PageEvent = page;
pdfDocument.Open();
pdfDocument.Add(ph1);
pdfDocument.Add(tblBlank);
pdfDocument.Add(tblAddInfo);
pdfDocument.Add(tblCon);
pdfDocument.Add(tblExhibition);
pdfDocument.Add(tblNotes);
pdfDocument.Add(iHeader);
pdfDocument.Add(jpg);
pdfDocument.Add(jpg1);
htmlparser.Parse(srHtmlText);
pdfDocument.Close();
Response.Write(pdfDocument);
//Response.End();}