1
Answer

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

Ankit Agarwal

Ankit Agarwal

9y
2.4k
1
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)