Dion Scher - 108 - Apr 17, 2014

I’m consistently getting the following error in my logs:

System.Web.HttpException (0x80004005): Server cannot set status after HTTP headers have been sent.
   at System.Web.HttpResponse.set_StatusCode(Int32 value)
   at System.Web.HttpResponseWrapper.set_StatusCode(Int32 value)
   at ServiceStack.Host.AspNet.AspNetResponse.set_StatusCode(Int32 value)
   at ServiceStack.HttpResponseExtensionsInternal.WriteErrorToResponse(IResponse httpRes, IRequest httpReq, String contentType, String operationName, String errorMessage, Exception ex, Int32 statusCode)
   at ServiceStack.ServiceStackHost.OnUncaughtException(IRequest httpReq, IResponse httpRes, String operationName, Exception ex)
   at ServiceStack.HttpResponseExtensionsInternal.WriteToResponse(IResponse response, Object result, ResponseSerializerDelegate defaultAction, IRequest request, Byte[] bodyPrefix, Byte[] bodySuffix)
   at ServiceStack.HttpResponseExtensionsInternal.WriteToResponse(IResponse httpRes, IRequest httpReq, Object result, Byte[] bodyPrefix, Byte[] bodySuffix)
   at ServiceStack.Host.RestHandler.<>c__DisplayClass5.<ProcessRequestAsync>b__0(Object response)
   at ServiceStack.Host.Handlers.ServiceStackHandlerBase.HandleResponse(Object response, Func2 callback, Func2 errorCallback)

Can anyone suggest a way of tracing and hopefully fixing the cause of this unhandled exception?

Regards,

Dion

You can register an exception handler and set a breakpoint to catch it, or log extra details about it, see: https://github.com/ServiceStack/ServiceStack/wiki/Error-Handling#customized-error-handling

Dion Scher:

Thanks
__________