开发者

How to Increase the MaxArrayLength in a WCF web.config - for uploading large files

开发者 https://www.devze.com 2023-03-29 07:35 出处:网络
I have dig all around the net for two days about it, and I can\'t make my asp.net web site to upload files bigger then 16Kb

I have dig all around the net for two days about it, and I can't make my asp.net web site to upload files bigger then 16Kb I'm using fileUploader,wcf, and I have service reference in the client. when I upload file in 30KB size it asked me to increase the MaxArrayLength.

The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing th开发者_JAVA百科e 2 MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 205847.

and it's just what I did, but it keeps complaining about this.

if I upload file in 1MB size, I get error 400.

The remote server returned an error: (400) Bad Request

please help

the client app.config:

<bindings>
  <basicHttpBinding> 

    <binding name="streamingBinding"
              transferMode="Streamed"/>


    <binding name="BasicHttpBinding_IBLServer" closeTimeout="00:01:00"
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
      useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="None" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<client>

  <endpoint address="http://localhost:8888/BLService.svc" binding="basicHttpBinding"
    bindingConfiguration="BasicHttpBinding_IBLServer" contract="WSRef.IBLServer"
    name="BasicHttpBinding_IBLServer" />
</client>

the WCF web.config:

 <system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
    <behavior name="BLServer.BackEndBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      <serviceTimeouts transactionTimeout="05:05:00" />
      <serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500"
       maxConcurrentInstances="2147483647" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />


<bindings>
  <basicHttpBinding>
    <binding name="streamingBinding"
              transferMode="Streamed"/>

    <binding name="BasicHttpBinding_IBLServer"
       maxBufferPoolSize="2147483647" maxBufferSize="2147483647" 
             maxReceivedMessageSize="2147483647">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows" />
      </security>
          <readerQuotas
              maxDepth="64"
            maxStringContentLength="2147483647"
             maxArrayLength="2147483647"
             maxBytesPerRead="4096"
             maxNameTableCharCount="16384"/>
    </binding>

  </basicHttpBinding>
</bindings>

<services>
  <service behaviorConfiguration="BLServer.BackEndBehavior" name="WSRef.BackEnd">
       <endpoint address="" binding="basicHttpBinding" 
              bindingConfiguration="BasicHttpBinding_IBLServer"
              contract="WSRef.IBLServer" />

  </service>


  <service name="StreamingService.Upload">
    <endpoint address=""
              binding="basicHttpBinding"
              bindingConfiguration="streamingBinding"
              contract="StreamingService.IUpload"/>
  </service>
</services>

files <16 KB are uploaded successfully.

can you please find out what I did wrong?


EDIT: Ok, I see you are doing it already... Are you sure yopu are mapping the bindings correctly. Check the first post below, they had a problem with the mapping of the binding.

Check these out:

Maximum array length quota

WCF service The maximum array length quota (16384) has been exceeded

Changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader

How to handle large file uploads via WCF?

Hope this helps.


I struggled with the same problem for hours. Finally, I realized that I was using a config file transform, and my maxArrayLength kept getting overwritten by the transform. Time for some caffeine.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号