Ankit Agarwal

Ankit Agarwal

  • NA
  • 379
  • 248k

Server can't append header after HTTP headers have been send

Oct 12 2015 7:34 AM
Hello,
 
 How to resolve this error "Server cannot append header after HTTP headers have been sent".

When i run second function for download excel, its getting error.

public void ExportQRCodeGenerateImageTableData(string data)
{
string attach = "attachment;filename=QRGenerateImage.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attach);
Response.ContentType = "application/ms-excel";
Response.Write(data);
Response.Flush();
//Response.End();
}

public void ExportAllCustomerTableData(string data)
{
string attach = "attachment;filename=CustomerDetails.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attach);// Error:Server cannot append header after HTTP headers have been sent.
Response.ContentType = "application/ms-excel";
Response.Write(data);
//Response.End();
Response.Flush();

}

Please help me.

Thanks in Advance

Ankit Agarwal
Software Engineer

Answers (1)