I have an aspx page (say 1.aspx), from where I first upload the pdf file, and then I want to redirect to the page with thanks. The code looks like this:
protected void btnSubmit_Click(object sender, EventArgs e) { string pathId = string.Empty; if (Page.IsValid) { try { pathId = hidId.Value; DownloadPDF(pathId); Response.Redirect("Thanks.aspx"); } catch (Exception ex) { throw ex; } } } protected void DownloadPDF(string pathId) { if (!(string.IsNullOrEmpty(pathId))) { try { Response.ContentType = "application/pdf"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + pathId + ".pdf"); string path = ConfigurationManager.AppSettings["Pdf_Path"].ToString() + "\\" + pathId.Trim() + ".pdf"; Response.TransmitFile(path); } catch (Exception ex) { throw ex; } finally { HttpContext.Current.ApplicationInstance.CompleteRequest(); } } }
The problem is that the file save dialog fits correctly, and I can also upload the file, but it does not redirect to the Thanks.aspx page.
How to resolve this?
source share