superó máxima maxbuffersize matriz los longitud leer datos cuota contenido change cadena c# asp.net .net web-services wcf

máxima - cómo aumentar MaxReceivedMessageSize cuando se llama a un WCF desde C#



se superó la cuota de longitud máxima de la matriz 16384 (2)

Posible duplicado:
Se ha superado la cuota máxima de tamaño de mensaje para los mensajes entrantes (65536)

Estoy usando WCF para subir y descargar archivos. la carga se realizó correctamente, pero cuando descargué un archivo grande, encontré este error

Error: Se ha excedido la cuota máxima de tamaño de mensaje para los mensajes entrantes (65536). Para aumentar la cuota, use la propiedad MaxReceivedMessageSize en el elemento de enlace apropiado.

Mi archivo Service.config tiene el siguiente código.

<system.web> <compilation debug="true" /> <httpRuntime executionTimeout="4800" maxRequestLength="2147483647" /> </system.web> <system.serviceModel> <bindings> <basicHttpBinding> <binding maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferPoolSize="524288"> <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> </binding> </basicHttpBinding> <!--<webHttpBinding> <binding maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" /> </webHttpBinding>--> </bindings> <services> <service name="WITSService.WITSService"> <clear /> <endpoint binding="basicHttpBinding" contract="WITSService.WITSService" /> </service> </services> <behaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false"/> <dataContractSerializer maxItemsInObjectGraph="2147483646"/> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="myEndPointBehavior"> <dataContractSerializer maxItemsInObjectGraph="2147483646"/> </behavior> </endpointBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel>

¿Puede alguien ayudarme a aumentar MaxReceivedMessageSize?


Cambie el enlace personalizado en el web.config para usar valores predeterminados más grandes. Escogí 2MB ya que es un tamaño razonable. Por supuesto, configurarlo en 2 GB (como sugiere su código) funcionará, pero lo deja más vulnerable a los ataques. Elija un tamaño que sea más grande que su solicitud más grande pero que no sea demasiado grande.

Marque esto: Usar solicitudes de mensajes grandes en Silverlight con WCF

<system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="TestLargeWCF.Web.MyServiceBehavior"> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> <bindings> <customBinding> <binding name="customBinding0"> <binaryMessageEncoding /> <!-- Start change --> <httpTransport maxReceivedMessageSize="2097152" maxBufferSize="2097152" maxBufferPoolSize="2097152"/> <!-- Stop change --> </binding> </customBinding> </bindings> <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> <services> <service behaviorConfiguration="Web.MyServiceBehavior" name="TestLargeWCF.Web.MyService"> <endpoint address="" binding="customBinding" bindingConfiguration="customBinding0" contract="TestLargeWCF.Web.MyService"/> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> </service> </services> </system.serviceModel>