Json web service max content length?

后端 未结 2 1535
离开以前
离开以前 2021-01-06 07:21

I have been building a Asp.net WCF web service with json format. Now I wanted to really test how its working when sending lots of data. The Content-Length of my http post is

相关标签:
2条回答
  • 2021-01-06 07:47

    As far as increasing the size of the request is concerned above mentioned answer is right but if you want to increase the size of the json response then you can do this by doing changes in the endpointBehaviors as mentioned below.

    Also not that response may vary according to the nesting of the data, as we may return list with nested properties.

    Assuming endpoint like this:

    <endpoint address="" binding="webHttpBinding" contract="WcfService1.IService1" behaviorConfiguration="ClientBehavior">
    For Client
            <endpointBehaviors>
              <behavior name="ClientBehavior">
                <dataContractSerializer maxItemsInObjectGraph="10000000"/>
              </behavior>
            </endpointBehaviors>
    
    For Server
          <serviceBehaviors>
            <behavior name="HostBehavior">
              <dataContractSerializer maxItemsInObjectGraph="10000000"/>
            </behavior>
          <serviceBehaviors>
    
    0 讨论(0)
  • 2021-01-06 07:52

    You need to increase the maxReceivedMessageSize in the binding configuration for WebHttpBinding. The default is 65536. See the WebHttpBinding configuration documentation for all of the information.

    Also note that you may need to increase the ASP.NET maxRequestLength via the httpRuntime configuration. The default is 4 MB but you may need to increase:

    <httpRuntime maxRequestLength="10000" />
    
    0 讨论(0)
提交回复
热议问题