C# WCF REST-IIS6的流媒体问题

C# WCF REST-IIS6的流媒体问题,c#,asp.net,wcf,iis,rest,C#,Asp.net,Wcf,Iis,Rest,我正在尝试使用WCF REST将文件流式传输到服务器。当我在控制台上托管该应用程序时,流式处理文件就消失了。也就是说,当我在循环中发送字节(读取要发送的文件),并在服务器端保留一个调试器时,每次循环都会命中服务。但现在我已经在IIS6上托管了该服务,只有在我关闭流时,该服务才会被命中。这是IIS6的问题还是我做错了什么 以下是web.config文件: <system.web> <compilation debug="true" targetFramework="4.0

我正在尝试使用WCF REST将文件流式传输到服务器。当我在控制台上托管该应用程序时,流式处理文件就消失了。也就是说,当我在循环中发送字节(读取要发送的文件),并在服务器端保留一个调试器时,每次循环都会命中服务。但现在我已经在IIS6上托管了该服务,只有在我关闭流时,该服务才会被命中。这是IIS6的问题还是我做错了什么

以下是web.config文件:

<system.web>
    <compilation debug="true" targetFramework="4.0" />
    <pages validateRequest="false" />
    <httpRuntime  maxRequestLength="102400" executionTimeout="3600" requestValidationMode="2.0" requestPathInvalidCharacters="" />

</system.web>

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <bindings>
        <webHttpBinding>
            <binding name="streamWebHttpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" receiveTimeout="01:00:00" sendTimeout="01:00:00" transferMode="Buffered" />
        </webHttpBinding>
    </bindings>
    <behaviors>
        <serviceBehaviors>
            <behavior name="FileUpload.FileUploadBehavior">
                <serviceMetadata httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
        </serviceBehaviors>
        <endpointBehaviors>
            <behavior name="RestBehavior">
                <webHttp />
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <services>
        <service name="FileUpload.UploadData" behaviorConfiguration="FileUpload.FileUploadBehavior" >
            <endpoint behaviorConfiguration="RestBehavior" address="" contract="FileUpload.IUpload" binding="webHttpBinding" bindingConfiguration="streamWebHttpBinding" />
        </service>
    </services>
</system.serviceModel>
错误发生在代码“st.Write(buf,0,bytesRead);”中,该代码表示-请求被中止:请求被取消。大约2分钟后

你试过这个吗

1) 设置的KeepAlive属性 HttpWebRequest为false(存在 性能冲击持续打开 (和关闭连接)

2) 扩展超时属性: WebRequest.ReadWriteTimeout, WebRequest.Timeout, RequestStream.WriteTimeout,以及 RequestStream.ReadTimeout

类似的问题。

你试过这个吗

1) 设置的KeepAlive属性 HttpWebRequest为false(存在 性能冲击持续打开 (和关闭连接)

2) 扩展超时属性: WebRequest.ReadWriteTimeout, WebRequest.Timeout, RequestStream.WriteTimeout,以及 RequestStream.ReadTimeout


类似的问题。

也许可以尝试在流上调用Flush()作为快速修复方法?我的代码在使用stream.Write发送流中的字节时出错。它给出错误-请求被中止:请求被取消。大约2分钟后,是在你叫同花顺之后吗?您可以发布您的错误,或者在该错误附近发布几行代码吗?使用客户端代码编辑代码,并将出现错误的位置放在哪里?或者尝试在流上调用Flush()作为快速修复方法?我的代码在使用stream.Write发送流中的字节时出错。它给出错误-请求被中止:请求被取消。大约2分钟后,是在你叫同花顺之后吗?你可以发布你的错误,或者在错误附近发布几行代码吗?用客户机代码编辑代码,并在哪里我得到了错误,这也不起作用。同样的问题仍然存在。即使在我的本地电脑上,我也会被暂停。这也没用。同样的问题仍然存在。即使在我的本地电脑上,我也会超时。
HttpWebRequest req = GetWebRequest("asyncfileupload", fileName);
            // 64 KB buffer
            byte[] buf = new byte[0x10000];
            Stream st = req.GetRequestStream();
            int bytesRead;

            using (FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read))
            {
                bytesRead = fs.Read(buf, 0, buf.Length);
                while (bytesRead > 0)
                {
                    st.Write(buf, 0, bytesRead);
                    bytesRead = fs.Read(buf, 0, buf.Length);
                }
                st.Close();
            }