2010-03-06 48 views
1

我有一个WCF服务,它本质上是在一个循环中运行并将文件输出到目录。IIS 6中的WCF:服务器无法在发送HTTP标头后设置状态

我得到我设法找到了与追踪这个有趣的错误启用

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"> 
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"> 
<EventID>524340</EventID> 
<Type>3</Type> 
<SubType Name="Error">0</SubType> 
<Level>2</Level> 
<TimeCreated SystemTime="2010-03-06T14:06:35.3593750Z" /> 
<Source Name="System.ServiceModel" /> 
<Correlation ActivityID="{f133e2e7-d86a-4ce3-8e4a-427e502817d0}" /> 
<Execution ProcessName="w3wp" ProcessID="2036" ThreadID="5" /> 
<Channel /> 
<Computer>SLOW</Computer> 
</System> 
<ApplicationData> 
<TraceData> 
<DataItem> 
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error"> 
<TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.ServiceOperationExceptionOnReply.aspx</TraceIdentifier> 
<Description>Replying to an operation threw a exception.</Description> 
<AppDomain>/LM/W3SVC/1/Root/ISDS-1-129123577914375000</AppDomain> 
<Source>System.ServiceModel.Dispatcher.ImmutableDispatchRuntime/38732823</Source> 
<Exception> 
<ExceptionType>System.Web.HttpException, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</ExceptionType> 
<Message>Server cannot set status after HTTP headers have been sent.</Message> 
<StackTrace> 
at System.Web.HttpResponse.set_StatusCode(Int32 value) 
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.SetStatusCode(Int32 statusCode) 
at System.ServiceModel.Channels.HttpOutput.HostedRequestHttpOutput.PrepareHttpSend(Message message) 
at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout) 
at System.ServiceModel.Channels.HttpRequestContext.OnReply(Message message, TimeSpan timeout) 
at System.ServiceModel.Activation.HostedHttpContext.OnReply(Message message, TimeSpan timeout) 
at System.ServiceModel.Channels.RequestContextBase.Reply(Message message, TimeSpan timeout) 
at System.ServiceModel.Channels.RequestContextBase.Reply(Message message) 
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.Reply(MessageRpc&amp; rpc) 
</StackTrace> 
<ExceptionString>System.Web.HttpException: Server cannot set status after HTTP headers have been sent. 
    at System.Web.HttpResponse.set_StatusCode(Int32 value) 
    at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.SetStatusCode(Int32 statusCode) 
    at System.ServiceModel.Channels.HttpOutput.HostedRequestHttpOutput.PrepareHttpSend(Message message) 
    at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout) 
    at System.ServiceModel.Channels.HttpRequestContext.OnReply(Message message, TimeSpan timeout) 
    at System.ServiceModel.Activation.HostedHttpContext.OnReply(Message message, TimeSpan timeout) 
    at System.ServiceModel.Channels.RequestContextBase.Reply(Message message, TimeSpan timeout) 
    at System.ServiceModel.Channels.RequestContextBase.Reply(Message message) 
    at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.Reply(MessageRpc&amp; rpc)</ExceptionString> 
</Exception> 
</TraceRecord> 
</DataItem> 
</TraceData> 
</ApplicationData> 
</E2ETraceEvent> 

我不知道是什么原因造成这个问题,任何想法从哪里开始试图解决这一问题?

在此先感谢。

回答

1

当服务发送响应时,它通过构建开始,然后以包发送响应。首先发回给客户端的是http头部,一旦头部在网络上发送,就不可能改变它们。

您可能有一些代码在运行过程中运行得太晚。

相关问题