1
Reply

Cannot redirect after HTTP headers have been sent

Prabu Spark

Prabu Spark

Dec 12 2014 5:03 AM
603
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");

Answers (1)