"Server cannot append header after HTTP headers have been sent" with IIS 7.5 / Server 2008 R2

Dec 9, 2010 at 12:55 AM
Edited Dec 9, 2010 at 1:04 AM

I just moved our site (which used to work fine) from IIS 7 (2008)  to IIS 7.5 (2008/R2).  

On R2, for every resource request, it looks like the server is recording an error:

System.Web.HttpException (0x80004005): Server cannot append header after HTTP headers have been sent.

Server stack trace: 
  at System.Web.HttpResponse.AppendHeader(String name, String value)
  at Miron.Web.MbCompression.FilesystemStorage.Excute(HttpContext context, String[] filesInfo, Minifier minify, Int32 versionHash, EncodingManager encodingMgr) in C:\My Projects\Prescreen Network\Code\3rd Party\MbCompression\Handlers\FileSystemStorage.cs:line 38
  at Miron.Web.MbCompression.CompressionHandlerBase.ProcessRequest(HttpContext context) in C:\My Projects\Prescreen Network\Code\3rd Party\MbCompression\Handlers\CompressionHandlerBase.cs:line 73
  at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
  at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
  at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)

Exception rethrown at [0]: 
  at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)
  at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
  at System.Action`1.EndInvoke(IAsyncResult result)
  at System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar)

However, I can confirm that the resources are being minified, so this is strange.

Does anybody know what's going on... or how to fix this?


Dec 9, 2010 at 2:11 AM
Edited Dec 9, 2010 at 2:12 AM

I'm happy to report that I finally got it working with the following:


I basically am now only using MbCompression for minifying.  And I use IIS for compressing.  Solved!  Whew!!

Also, I had to turn on reflection because of another issue: "Unable to validate data.".  With these settings it seems to be holding up now.