The Remote Server Returned an Unexpected Response: (413) Request Entity Too Large

The remote server returned an unexpected response: (413) Request Entity Too Large.

For the record

I think I got it.
The Web.Config from the service does not have the binding information.
I placed this info in it, and voila!

<bindings>
<basicHttpBinding>
<binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>

Note here that the binding did not have a name specified.

The remote server returned an error: (413) Request Entity Too Large. WCF

You changed the configuration for the binding, but I don't see anywhere in your service's configuration file where you actually use the binding ("BasicHttpBinding_Portal").

You can do one of two things. Either assign that binding to an explicit endpoint via the bindingConfiguration attribute of the <service> tag, or make the configuration you set up as the default for basicHttpBinding by omitting the name attribute on the <binding> tag. Since you don't have an explicit endpoint defined, I'd recommend the second approach:

<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" />
</basicHttpBinding>
</bindings>

The key point here is that you must tell the service to use the binding you've specified. If you don't, the default values for the binding will be used. By omitting the name attribute on the binding configuration, you're telling the framework to use that configuration for any basicHttpBinding requests.

The remote server returned an error: (413) Request Entity too Large WCF

The main problem is that we don’t apply the configuration on the server-side. Since the server-side uses ProtocolMapping feature to enable the service works over HTTPS protocol, we should modify and apply the configuration on the BasicHttpsBinding instead of the BasicHttpBinding.

Please refer to the below configuration(Server-side).

<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport" />
</binding>
</basicHttpBinding>
<basicHttpsBinding>
<binding name="httpsBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport" />
</binding>
</basicHttpsBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" bindingConfiguration="httpsBinding"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

Feel free to let me know if the problem still exists.

c# - The remote server returned an unexpected response: (413) Request Entity Too Large

Try using this for your binding:

      <basicHttpBinding>
<binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>

I know you already modified maxReceivedMessageSize, so with the above you're also tampering with readerQuotas.

You can also try increasing the uploadReadAheadSize in IIS:

<location path="THENAMEOFTHESITEYOUHAVE" overrideMode="Allow">
<system.webServer>
<asp />
<serverRuntime uploadReadAheadSize="2147483647" />
</system.webServer>

The remote server returned an unexpected response: (413) Request Entity Too Large.?

Try this,

<bindings>
<basicHttpBinding>
<binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>

Instead of these lines in your code,

<bindings>
<basicHttpBinding>
<binding name="SampleBinding"
messageEncoding="Text"
closeTimeout="00:02:00"
openTimeout="00:02:00"
receiveTimeout="00:20:00"
sendTimeout="00:02:00"
allowCookies="false"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
textEncoding="utf-8"
transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2000000"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None"
proxyCredentialType="None"
realm="">
</transport>
</security>
</binding>
</basicHttpBinding>
</bindings>

I hope this helps you. :)

The remote server returned exception: (413) Request Entity Too Large

The solution was found in this post (How to override WebServiceHostFactory MaxReceivedMessageSize?)

The problem was the factory creating the host for the service, because it was a default SharePoint factory/host it did not respond to the changes made in the different web.config files. The solution was therefore to replace the factories with custom factories that created the hosts with the parameters that would normally be specified in the web.config files.



Related Topics



Leave a reply



Submit