I have a WCF SOAP service and I am trying to submit a file to the service that is too large (128KB). I have scoured the internet and found many suggestions about adding the maxReceivedMessageSize, maxBufferSize, and other such attributes, but to no avail. I have also added the maxRequestLength to the httpRuntime but that doesn't work either. Not matter what I do I keep getting HTTP Error 413: Request Entity Too Large.
Error
HTTP Error 413: Request Entity Too Large.
Web Config
<httpRuntime targetFramework="4.5.1" maxRequestLength="1048576"/>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="SomeBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" openTimeout="00:20:00"
receiveTimeout="00:20:00" closeTimeout="00:20:00" sendTimeout="00:20:00">
<readerQuotas maxDepth="200" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Even though you've set larger quotas in your binding, that binding is not being used by your service because it's never assigned to an endpoint or set as the default binding for
basicHttpBinding
.Since you don't have an explicit endpoint defined in your config file, you can set your binding configuration as the default for
basicHttpBinding
by omitting thename
attribute, like this:Without making it the default for all requests that use
basicHttpBinding
(or assigning it to an explicit endpoint), the service will create the binding with the default (and smaller) values.For more information on default bindings (and endpoints and behaviors), see A Developer's Introduction to Windows Communication Foundation 4.