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

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.

StackTrace:
   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.

http://asp.syncfusion.com/demos/reporting/xlsio/Getting%20Started/CreateSpreadsheet/CS/CreateSpreadsheet.aspx

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.

Thanks,
Sridhar.S


Loader.
Up arrow icon