I am trying to upload large files (up to 200 MB) via ASP.NET web forms and store them in a database. I can upload large files using the FileUpload control, and I have setup in SQL Server as VarBinary (MAX) FileStream to store files from the outside. I want to transfer the downloaded file using the WCF service to the database, and thatβs where I got stuck. The only problem I encounter is when I try to transfer a file from code to the WCF service.
Settings :
web.config client in ASP.NET application
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IFileTransfer" maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
transferMode="Streamed" messageEncoding="Mtom"
sendTimeout="24.20:31:23.6470000" receiveTimeout="24.20:31:23.6470000">
<readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxDepth="2147483647" maxStringContentLength="2147483647"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:25333/FileTransfer.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IFileTransfer" contract="FileTransfer.IFileTransfer"
name="BasicHttpBinding_IFileTransfer" />
</client>
</system.serviceModel>
Web.config server in WCF application
<system.serviceModel>
<services>
<service name="Ward.POC1.FileStream">
<endpoint address="ep1" binding="basicHttpBinding" contract="WcfServiceHost.IFileTransfer">
<identity>
<dns value="localhost" />
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
transferMode="Streamed" messageEncoding="Mtom"
sendTimeout="24.20:31:23.6470000" receiveTimeout="24.20:31:23.6470000">
<readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxDepth="2147483647" maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
I used transferMode = "Streamed" with the following contract definition:
[ServiceContract]
public interface IFileTransfer
{
[OperationContract]
Stream GetFile(Guid fileId);
[OperationContract]
void AddFile(Stream fileStream);
}
Depending on the change in configuration settings, I get the following exception:
. . - "24.20: 31: 23.6100000".
WCF : (400) .
- ASP.NET WCF? Streaming. - , /chunking, .