2011-08-18 69 views
1

我已經圍繞它挖了兩天的網絡,並且我無法讓我的asp.net網站上傳大於16Kb的文件 我正在使用fileUploader,wcf,並且我在客戶端有服務引用。 當我上傳30KB大小的文件時,它要求我增加MaxArrayLength。如何增加WCF web.config中的MaxArrayLength - 用於上傳大文件

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

這就是我所做的,但它一直在抱怨。

,如果我在1MB大小上傳文件,我得到錯誤400

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

請幫助

客戶端的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> 

的WCF網.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> 

文件<已成功上傳16 KB。

你能找出我做錯了什麼嗎?

回答

1

編輯:好吧,我看到你已經在做...你確定yopu正確映射綁定。檢查下面的第一篇文章,他們遇到了綁定映射的問題。

檢查這些了:

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?

希望這有助於。

+0

嗨,我看着thos鏈接,但問題仍然存在。 – Rinacom

+0

我還能做些什麼? – Rinacom

+0

好吧,我有一個錯誤,我在想我的客戶端是調用WS引用實例的客戶端。所以我改變了「maxArrayLength」的web.config並不是正確的。但即使是現在,當我認爲我的客戶端是ASP.NET proj時,錯誤仍然出現「最大陣列長度配額(16384)已被超出」。我確信我這次做得很好,因爲當我減小數值 - maxArrayLength =「100」時,我的網站顯示了同樣的錯誤,數值爲「100」,但是當我將它增大到16384時,它仍然抱怨說當前的maxArrayLength是16384,我需要改變它。 – Rinacom

0

我掙扎了幾個小時的同樣的問題。最後,我意識到我正在使用配置文件轉換,並且我的maxArrayLength不斷被轉換覆蓋。一些咖啡因的時間。

相關問題