2014-12-05 74 views
-2

當我運行應用程序時,我收到以下消息: 傳入消息的最大消息大小配額(65536)已被超出。要增加配額,請在適當的綁定元素上使用MaxReceivedMessageSize屬性。增加消息大小配額

<configuration> 
<connectionStrings> 
    <add name="abc" connectionString="Data Source=xyz;Initial Catalog=abc;Persist Security Info=True;User ID=abc;Password=abc"/> 
    </connectionStrings> 
<system.web> 
<compilation debug="true"/> 
    <globalization uiCulture="en-GB" culture="en-GB"/> 
<system.serviceModel> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> 
<bindings> 
<basicHttpBinding> 
<binding name="PictureBinding" maxReceivedMessageSize="2000000" maxBufferSize="2000000"> 
<readerQuotas 
maxStringContentLength="2147483647" 
maxArrayLength="2147483647" 
maxBytesPerRead="2147483647" 
maxNameTableCharCount="2147483647" /> 
</binding> 
</basicHttpBinding> 
</bindings> 
<behaviors> 
<serviceBehaviors> 
<behavior name="WCFservice.Service1Behavior"> 
<serviceDebug includeExceptionDetailInFaults="false" /> 
</behavior> 
<behavior name=""> 
<serviceMetadata httpGetEnabled="true" /> 
<serviceDebug includeExceptionDetailInFaults="false" /> 
</behavior> 
</serviceBehaviors> 
</behaviors> 
<services> 
<service behaviorConfiguration="WCFservice.Service1Behavior" name="WCFservice.Service1"> 
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="PictureBinding" contract="WCFservice.IService1"> 
</endpoint> 
<endpoint address="web" binding="webHttpBinding" contract="WCFservice.IService1"> 
</endpoint> 
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
</service> 
</system.serviceModel> 
<system.webServer> 
<modules runAllManagedModulesForAllRequests="true"/> 
</system.webServer> 
</configuration> 

回答

1

您可以使用此配置

<bindings> 
    <basicHttpBinding> 
     <binding name="basicHttp" allowCookies="true" 
       maxReceivedMessageSize="20000000" 
       maxBufferSize="20000000" 
       maxBufferPoolSize="20000000"> 
      <readerQuotas maxDepth="32" 
       maxArrayLength="200000000" 
       maxStringContentLength="200000000"/> 
     </binding> 
    </basicHttpBinding> 
</bindings> 

你可以做到這一點務實太

BasicHttpBinding httpBinding = new BasicHttpBinding(); 
httpBinding.MaxReceivedMessageSize = 2147483647; 
httpBinding.MaxBufferSize = 2147483647; 
+0

感謝先生,其工作 – 2014-12-05 09:49:53