I have just recently published a fully netcore 2.2 app running InProcess on Windows Server. Using ServiceStack’s .Core package (5.4.0) and I have the following exceptions being thrown. Not sure what it’s about. Any ideas on how to stop it?
System.ArgumentException: Value does not fall within the expected range.
at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.SetResponseHeaders()
at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.ProduceStart(Boolean flushHeaders)
at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.InitializeResponse(Boolean flushHeaders)
at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.<>c__DisplayClass310_0.<<WriteAsync>g__WriteFirstAsync|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Server.IIS.Core.HttpResponseStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at Microsoft.AspNetCore.Server.IIS.Core.WrappingStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at ServiceStack.Text.JsonSerializer.SerializeToStream[T](T value, Stream stream)
at ServiceStack.Serialization.JsonDataContractSerializer.SerializeToStream[T](T obj, Stream stream)
at ServiceStack.Host.ContentTypes.<>c__DisplayClass30_0.<GetStreamSerializerAsync>b__0(IRequest httpReq, Object dto, Stream stream)
at ServiceStack.HttpResponseExtensionsInternal.WriteToResponse(IResponse response, Object result, StreamSerializerDelegateAsync defaultAction, IRequest request, Byte[] bodyPrefix, Byte[] bodySuffix, CancellationToken token)
System.InvalidOperationException: The response headers cannot be modified because the response has already started.
at Microsoft.AspNetCore.HttpSys.Internal.HeaderCollection.ThrowIfReadOnly()
at Microsoft.AspNetCore.HttpSys.Internal.HeaderCollection.set_Item(String key, StringValues value)
at Microsoft.AspNetCore.Http.Internal.DefaultHttpResponse.set_ContentType(String value)
at ServiceStack.HttpResponseExtensionsInternal.WriteErrorToResponse(IResponse httpRes, IRequest httpReq, String contentType, String operationName, String errorMessage, Exception ex, Int32 statusCode)
at ServiceStack.HostContext.RaiseAndHandleUncaughtException(IRequest httpReq, IResponse httpRes, String operationName, Exception ex)
at ServiceStack.HttpResponseExtensionsInternal.HandleResponseWriteException(Exception originalEx, IRequest request, IResponse response, String defaultContentType)
at ServiceStack.HttpResponseExtensionsInternal.WriteToResponse(IResponse response, Object result, StreamSerializerDelegateAsync defaultAction, IRequest request, Byte[] bodyPrefix, Byte[] bodySuffix, CancellationToken token)
at ServiceStack.HttpResponseExtensionsInternal.WriteToResponse(IResponse response, Object result, StreamSerializerDelegateAsync defaultAction, IRequest request, Byte[] bodyPrefix, Byte[] bodySuffix, CancellationToken token)
at ServiceStack.Host.Handlers.ServiceStackHandlerBase.HandleResponseNext(IRequest httpReq, IResponse httpRes, Object response)
at ServiceStack.Host.Handlers.ServiceStackHandlerBase.HandleResponse(IRequest httpReq, IResponse httpRes, Object response)
at ServiceStack.Host.Handlers.GenericHandler.ProcessRequestAsync(IRequest httpReq, IResponse httpRes, String operationName)