WCF REST를 사용하여 서버로 파일을 스트리밍하려고합니다. 콘솔에서 응용 프로그램을 호스팅 할 때 스트리밍 파일이 저장됩니다. I.E. 바이트를 루프 (전송할 파일 읽기)로 전송하고 서버 끝의 디버거를 유지하면 모든 루프에 대해 서비스가 중단됩니다. 그러나 IIS 6에서 서비스를 호스팅 했으므로 스트림을 닫을 때만 서비스가 중단됩니다. 이 문제가 IIS6에 문제가 있습니까? st.WriteWCF REST - IIS6 스트리밍 문제
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();
}
오류 코드 발생 ": 클라이언트 코드 plaing을
:
이<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>
편집을 도와주세요 : 다음
는의 Web.config입니다 (buf, 0, bytesRead); " 요청 - 요청이 취소되었습니다. 요청이 취소되었습니다. ~ 2 분 후
아마도 스트림의 Flush()를 빠른 수정으로 호출 해보십시오. – oleksii
Stream.Write를 사용하여 스트림에서 바이트를 보내는 동안 내 코드에서 오류가 발생합니다. 오류를 발생시킵니다 - 요청이 중단되었습니다 : 요청이 취소되었습니다. ~ 2 분 후 – Ankit
플러시를 호출 한 후입니까? 오류 근처에 몇 줄의 코드를 올리시겠습니까? – oleksii