We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Server cannot set content type after HTTP headers have been sent.

I am stuck as to why we are getting this error now. The code has worked for some time and now we are having issues.  Any ideas why we are getting this? I have done research on the web and most people say that you need to set the BufferOutput of the response to true. I have tried this an it does not fix the issue.

Possible problem code: 
workbook.SaveAs(Replace(title, " ", ""), ExcelSaveType.SaveAsXLS, response, ExcelDownloadType.PromptDialog)

ExceptionMessage: Server cannot set content type after HTTP headers have been sent.

   at System.Web.HttpResponse.set_ContentType(String value)
   at System.Web.HttpResponseInternalWrapper.set_ContentType(String value)
   at System.Web.UI.PageRequestManager.RenderPageCallback(HtmlTextWriter writer, Control pageControl)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.Page.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

1 Reply

SR Sridhar Syncfusion Team June 10, 2013 04:56 AM UTC

Hi Bob Wallace,

Thank you for using Syncfusion products.

We are unable to reproduce the above reported exception at our side. Could you please try to save the excel file specfied in the below online sample link and let us know if this helps you.


If you still face the issue, please update us with the sample which reproduces the exception, the scenario for the creation of the sample.

Please let me know if you have any further clarifications.


Live Chat Icon For mobile
Up arrow icon