运行应用程序时收到以下消息: 已超出传入邮件的最大邮件大小限额(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>
答案 0 :(得分: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;