0

I have a website and wcf service, database is mongodb.

I got error while trying to upload a class has filestream property (bigger than 4mb). All fine when i try to upload smaller sizes.

How can i increase upload limit ?

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

Client config:

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime requestValidationMode="2.0" executionTimeout="360" maxRequestLength="100000" enableVersionHeader="false" />
    <authentication mode="Forms" >
      <forms loginUrl="~/Login.aspx" timeout="2880" protection="All" path="/" />
    </authentication>
    <httpHandlers>
      <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
    </httpHandlers>
  </system.web>
  <location path="Default.aspx">
    <system.web>
      <authorization>
        <deny users="?" />
      </authorization>
    </system.web>
  </location>
  <system.webServer>
    <staticContent>
      <remove fileExtension=".woff" />
      <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
      <remove fileExtension=".woff2" />
      <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
    </staticContent>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" />
    </handlers>
  </system.webServer>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IMyService" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
          <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:52237/MyService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyService"
        contract="MyService.IMyService" name="BasicHttpBinding_IMyService" />
    </client>
  </system.serviceModel>
</configuration>

Wcf service config:

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
    <globalization culture="tr-TR" uiCulture="tr-TR"/>
    <pages controlRenderingCompatibilityVersion="4.0"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="MyBinding" maxReceivedMessageSize="10485760" maxBufferPoolSize="2147483647">
          <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="false"/>
  </system.webServer>
</configuration>
Mennan
  • 4,451
  • 13
  • 54
  • 86

4 Answers4

0

just change the maxReceivedMessageSize="10485760" in client side config to maxBufferPoolSize="2147483647".

Mohammad
  • 2,724
  • 6
  • 29
  • 55
0

Try this:

<bindings>
  <wsHttpBinding>
    <!--allow big messages: 10mb = 10 * 1048576 = 10485760-->
    <binding name="binding_name" maxReceivedMessageSize="10485760" messageEncoding="Mtom" sendTimeout="00:02:00">
      <readerQuotas maxArrayLength="10485760"/>
    </binding>
  </wsHttpBinding>
</bindings>

This is part of my config on server-side :) I had exact same issue and this modification solved it.

Michał Turczyn
  • 32,028
  • 14
  • 47
  • 69
-1

Add these under the < system.serviceModel >

<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="32"
maxArrayLength="2147483647"
maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
Hassan Shouman
  • 275
  • 4
  • 13
-1

I found solution. wcf service config:

<configuration>
  <appSettings>
    <add key="ConnectionString" value="mongodb://login.f8.com.tr:19191"/>
    <add key="DatabaseName" value="F8Mutabakat"/>
  </appSettings>
  <!--
    For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.

    The following attributes can be set on the <httpRuntime> tag.
      <system.Web>
        <httpRuntime targetFramework="4.5" />
      </system.Web>
  -->
  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
    <globalization culture="tr-TR" uiCulture="tr-TR"/>
    <pages controlRenderingCompatibilityVersion="4.0"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <!--<behavior name="F8ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceCredentials>
            <serviceCertificate findValue="F8Mutabakat" storeLocation="LocalMachine"
              storeName="My" x509FindType="FindBySubjectName" />
            <userNameAuthentication userNamePasswordValidationMode="Custom"
              customUserNamePasswordValidatorType="F8LocalService.UserNamePassValidator, F8LocalService" />
          </serviceCredentials>
        </behavior>-->
        <behavior>

          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="Web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <services>
      <!-- The name of the service -->
      <service name="F8LocalService.F8mBelgeService">
        <!--you can leave the address blank or specify your end point URI-->
        <endpoint binding="basicHttpBinding" bindingConfiguration="F8ServiceMaxTransfer" contract="F8LocalService.IF8mBelgeService" />
      </service>
    </services>

    <bindings>
      <basicHttpBinding>

        <binding name="F8ServiceMaxTransfer" maxReceivedMessageSize="2147483647"
        maxBufferSize="2147483647"
                 transferMode="Streamed"
        maxBufferPoolSize="2147483647">
          <readerQuotas maxDepth="32"
          maxArrayLength="2147483647"
          maxStringContentLength="2147483647"/>
          <security mode="Message">
            <message clientCredentialType="UserName"/>
          </security>
        </binding>

        <!--<binding name="F8ServiceBinding" maxReceivedMessageSize="10485760" maxBufferPoolSize="2147483647">
          <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      -->
    <!--<security mode="Message">
        <message clientCredentialType="UserName"/>
      </security>-->
    <!--
    </binding>-->
  </basicHttpBinding>

</bindings>
<protocolMapping>
  <add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>

Mennan
  • 4,451
  • 13
  • 54
  • 86