Cannot redirect after HTTP headers have been sent
Hi sir,
I am getting the error "Cannot redirect after HTTP headers have been sent"
while redirecting to another page after the download operation.
I shared the code for your reference. Kindly give me the solution for this problem.
Default.aspx.cs:
*********************
Response.Clear();
Response.ContentType = "application/pdf";
string filePath = "d:\\" + filename + ".pdf";
Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", filePath));
Response.OutputStream.Write(bytes, 0, bytes.Length);
Response.Buffer = true;
Response.OutputStream.Flush();
Response.OutputStream.Close();
Response.Flush();
Response.Close();
Response.Redirect("StudentHome.aspx");