maxReceivedMessageSize and maxBufferSize in app.config

后端 未结 7 769
心在旅途
心在旅途 2020-12-16 09:30

How to increase maxReceivedMessageSize and maxBufferSize parameters in app.config file to 2000000 before running the application.

相关标签:
7条回答
  • 2020-12-16 09:49

    You need to do that on your binding, but you'll need to do it on both Client and Server. Something like:

    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding maxBufferSize="64000000" maxReceivedMessageSize="64000000" />
            </basicHttpBinding>
        </bindings>
    </system.serviceModel>
    
    0 讨论(0)
  • 2020-12-16 09:50

    You can do that in your app.config. like that:

    maxReceivedMessageSize="2147483647" 
    

    (The max value is Int32.MaxValue )

    Or in Code:

    WSHttpBinding binding = new WSHttpBinding();
    binding.Name = "MyBinding";
    binding.MaxReceivedMessageSize = Int32.MaxValue;
    

    Note:

    If your service is open to the Wide world, think about security when you increase this value.

    0 讨论(0)
  • 2020-12-16 09:50

    If you are using a custom binding, you can set the values like this:

    <customBinding>
        <binding name="x">
            <httpsTransport maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
        </binding>
    </customBinding>
    
    0 讨论(0)
  • 2020-12-16 09:51

    Open app.config on client side and add maxBufferSize and maxReceivedMessageSize attributes if it is not available

    Original

      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="Service1Soap"/>
          </basicHttpBinding>
        </bindings>
    

    After Edit/Update

      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="Service1Soap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
          </basicHttpBinding>
        </bindings>
    
    0 讨论(0)
  • 2020-12-16 09:56

    Easy solution: Check if it works for you..

    Goto web.config

    Find binding used by client.

    change as,

    maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"

    Done.

    0 讨论(0)
  • 2020-12-16 10:00

    The currently accepted answer is incorrect. It is NOT required to set maxBufferSize and maxReceivedMessageSize on the client and the server binding. It depends!

    If your request is too large (i.e., method parameters of the service operation are memory intensive) set the properties on the server-side, if the response is too large (i.e., the method return value of the service operation is memory intensive) set the values on the client-side.

    For the difference between maxBufferSize and maxReceivedMessageSize see MaxBufferSize property?.

    0 讨论(0)
提交回复
热议问题