Mikkel Bach Nielsen
Mikkel Bach Nielsen

Reputation: 11

WCF 4 REST Max recevied message size

I am testing a WCF 4 Rest interface.

When trying to do a get using fiddler I receive this: "The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element."

I have tried to increase it in my web.config file but it does not come through:

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<standardEndpoints>
  <webHttpEndpoint>
    <!-- 
        Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
        via the attributes on the <standardEndpoint> element below
    -->
    <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="327680" />
  </webHttpEndpoint>
</standardEndpoints>

Thanks, Mikkel

Upvotes: 1

Views: 4573

Answers (4)

Ajoy
Ajoy

Reputation: 11

Try it by following web-config(in Service) settings :

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
    <standardEndpoints>

            <webHttpEndpoint>
                <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"                                        
                                  crossDomainScriptAccessEnabled="true" 
                                  maxReceivedMessageSize="2147483647" 
                                  maxBufferSize="2147483647" 
                                  maxBufferPoolSize="4194304" />
            </webHttpEndpoint>

    </standardEndpoints>

    <bindings>
        <webHttpBinding>
            <binding>
                <readerQuotas maxStringContentLength="2147483647"/>
            </binding>
        </webHttpBinding>
    </bindings>

</system.serviceModel>

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

Upvotes: 1

Mike O&#39;Connor
Mike O&#39;Connor

Reputation: 3813

I just ran into this today, and it was a bit of a pain to figure out. The following config (adapted from the answer to this question) should work:

<system.web>
  <!-- maxRequestLength is in KB -->
  <httpRuntime maxRequestLength="320" />
</system.web>

<system.serviceModel>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
  <bindings>
    <webHttpBinding>
      <binding maxReceivedMessageSize="327680" />
    </webHttpBinding>
  </bindings>
  <standardEndpoints>
    <webHttpEndpoint>
      <standardEndpoint name=""
                        helpEnabled="true"
                        automaticFormatSelectionEnabled="true" />
    </webHttpEndpoint>
  </standardEndpoints>
</system.serviceModel>

I'm pretty sure you need the httpRuntime bit because you're running with aspNetCompatibilityEnabled set to true.

Upvotes: 1

larsw
larsw

Reputation: 3830

Have you increased the MaxReceivedMessageSize value in both the web.config (service-side) and in your client's configuration (file)?

If so, can you also try to increase MaxBufferSize to the same value as MaxReceivedMessageSize?

Upvotes: 0

amit
amit

Reputation: 2123

Capture WCF traces at verbose level with ActivityTracing and check what enpoints are applied on your service under Construct ServiceHost and Open ServiceHost activity. That will give you idea whether above configuration is applied on service or not.

HTH, Amit

Upvotes: 0

Related Questions