0

i am writing a code which will upload selected files to some server using WCF. i am using .Net 4.0. I am having one aspx page with fileupload control. where user browse the file and click save i am keeping these files (read in byte then converted to base64) in session object. there is one more button called Upload. when i clicked on upload i am calling WCF service and passing object from session. following is my binding config from client side

<i>   
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_DefaultService" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" bypassProxyOnLocal="false" 
             transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
             maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

      <reliableSession ordered="true" inactivityTimeout="00:20:00" enabled="false" />
       <security mode="Message">
        <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
</i>

and following one from Server

<i>
<wsHttpBinding>
<binding name="WSHttpBinding_DefaultService" closeTimeout="0:20:00"
  openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"
  bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
  maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
  messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
  allowCookies="false">
  <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
    maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
  <reliableSession ordered="true" inactivityTimeout="00:20:00"
    enabled="false" />
  <security mode="Message">
    <message clientCredentialType="Windows" negotiateServiceCredential="true"
      algorithmSuite="Default" />
  </security>
</binding>
</wsHttpBinding>
</i>  

also i made chages to httpruntime

<i> <httpRuntime requestValidationMode="2.0"  executionTimeout="90" maxRequestLength="2097151"/></i>

issue is whenever i try to select multiple files with total size greater than 2.5 MB my object is not getting transported to WCF it's throwing error

<i>The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. >>>> The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. >>>> Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. >>>> An existing connection was forcibly closed by the remote host >>>>     </i>

so what i need to do? i am trying to find solution with wsHttpBinding so any suggestions?

1 Answers1

1

In your httpRuntime configuration, the property maxRequestLength="2097151" indicates a max request size of about 2.1 MB. Increasing that should increase your maximum file size.

For larger files, you may want to create some kind of streaming implementation, so you don't need to be limited by the maxRequestLength property.

BTownTKD
  • 7,911
  • 2
  • 31
  • 47