Request Entity Too Large I've tried everything

118 Views Asked by At

I've searched this and tried everything that SO has to offer. I've been at this for quite some time and I cannot find in my web.config what is wrong. I'm getting the message "The remote server returned an unexpected response: (413) Request Entity Too Large."

I can't for the life of me figure out what I'm doing wrong! Help!

Here is my web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>

    <system.web>
      <compilation targetFramework="4.6" debug="true">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <caching>
      <outputCacheSettings>
        <outputCacheProfiles>
          <add name="DefaultCache" duration="60" varyByParam="none" />
        </outputCacheProfiles>
      </outputCacheSettings>
    </caching>
    <authentication mode="Windows" />
    <pages controlRenderingCompatibilityVersion="4.0" />
  </system.web>

  <system.webServer>
      <security>
          <requestFiltering>
              <requestLimits maxAllowedContentLength="3521478366" />
          </requestFiltering>
      </security>
  </system.webServer>

  <system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
    <bindings>

        <basicHttpBinding>
            <binding name="BasicHttpEndpointBinding" allowCookies="true"
                     maxReceivedMessageSize="2147483647"
                     maxBufferSize="2147483647"
                     maxBufferPoolSize="2147483647">
                <readerQuotas maxDepth="32"
                              maxArrayLength="2147483647"
                              maxStringContentLength="2147483647"/>
            </binding>
        </basicHttpBinding>

    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="false" />
          <!-- 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>
      <endpointBehaviors>
        <behavior name="restBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <services>

        <service name="TruckService.TruckService">
        <endpoint 
            binding="basicHttpBinding" 
            bindingConfiguration="BasicHttpEndpointBinding" 
            contract="TruckService.ITruckService">
            <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>

      </service>
    </services>
  </system.serviceModel>
  <system.webServer>
      <modules runAllManagedModulesForAllRequests="true" />
    <directoryBrowse enabled="false" showFlags="Date, Time, Size, Extension" />
  </system.webServer>
  <connectionStrings>

        <!-- removed for security purposes -->

  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

What I've tried:

how to increase MaxReceivedMessageSize when calling a WCF from C#

The maximum message size quota for incoming messages (65536) has been exceeded

1

There are 1 best solutions below

2
Jiayao On

First of all, you need to keep the file transfer format of the server-side and the client-side the same. Deviation may cause this problem.

In addition, on the premise that increasing the message size and buffer size does not work, you can try to change a value: maxitemsinobjectgraph like this:

<behaviors>
  <endpointBehaviors>
    <behavior name="restBehavior">
      <dataContractSerializer maxItemsInObjectGraph="1365536" />
    </behavior>
 </behaviors>
 <serviceBehaviors>
    <behavior name="restBehavior">
      <dataContractSerializer maxItemsInObjectGraph="1365536" />
    </behavior>
 </serviceBehaviors>