I have a WCF Service Application running that requires byte arrays to be sent to the service and be returned from the service. I am getting the 413 "Request Too Large" error. I have researched this error and there are many responses like changing the binding element to include maxReceivedMessageSize, adding the readerQuotes element to the binding element with settings and other changes. However, my web.config does not have the binding element. I changed it on the client side but this made no difference. It would make since that the server side (were the service runs) would be where these settings need to be done at. I am at a loss as to where I make the changes on the server side. What settings am I missing to take care of sending and receiving larger byte arrays? Here is the web.config the server is using:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
Starting with WCF 4.0, by default (with no endpoints or bindings explicitly defined) WCF will create default endpoints with basicHttpBinding
. This makes the configuration less cluttered, but also means you get the default values for the binding. There are two ways to resolve this when you need non-default settings for a binding (on the service side):
First, you can add a default binding configuration by ommitting the name
attribute, like this:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding closeTimeout="........... />
</basicHttpBinding>
</bindings>
Or, you can name your binding configuration and then create an explicit endpoint that uses that configuration:
<system.serviceModel>
<services>
<service name=".....>
<endpoint address="" bindingConfiguration="MyBasicHttpBinding"..... />
The second example assumes you have a binding configuration named "MyBasicHttpBinding" in your bindings section.
I've ommitted a good deal of the configuration for simplicity. Let me know if you need further details.