none
Upload large size. Getting error 400 Request RRS feed

  • Question

  • Hi guys, I try to upload a large file to service but I'm in trouble now, it's getting error (400) Bad request, I tried to follow many solutions but it didn't work.

    Here is my web.config:

    <?xml version="1.0"?>
    <configuration>
    
      <system.web>
        <compilation debug="true" targetFramework="4.0" />
        <httpRuntime maxRequestLength="67108864"/>
      </system.web>
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <!-- buffer: 64KB; max size: 2GB -->
            <binding name="JFServiceBinding" transferMode="Streamed"
                       messageEncoding="Mtom"
                      maxReceivedMessageSize="67108864" maxBufferSize="65536"
                      closeTimeout="00:01:00" openTimeout="00:01:00"
                      receiveTimeout="00:10:00" sendTimeout="00:01:00">
              <security mode="None">
                <transport clientCredentialType="None" />
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the value below to false before deployment -->
              <serviceMetadata httpGetEnabled="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>
            <behavior name="JFServiceBehavior">
              <serviceMetadata httpGetEnabled="True" httpsGetEnabled="False" />
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <services>
          <service behaviorConfiguration="JFServiceBehavior"
         name="JFService.JFService" >
            <endpoint address="" binding="basicHttpBinding" contract="JFService.IJFService"
                      bindingConfiguration="JFServiceBinding" >
            </endpoint>
          </service>
        </services>
        <serviceHostingEnvironment 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>
    

    and here is my app.config 

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00" transferMode="StreamedRequest" sendTimeout="00:10:00"
                        openTimeout="00:01:00" maxBufferPoolSize="67108864" maxReceivedMessageSize="67108864" />
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://169.254.113.70/JFService/Service1.svc"
                    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
                    contract="JapaneseFlashcardService.IService1" name="BasicHttpBinding_IService1" />
            </client>
        </system.serviceModel>
    <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
    

    Any help will be appreciated

    Thanks for help!!!

    Monday, August 4, 2014 4:13 AM

All replies

  • Hi,

    >>Getting error 400 Request when upload a large file

    First please try to increase the readerQuotas in the both client and service side as following:

    <basicHttpBinding>
                <binding name="JFServiceBinding" transferMode="Streamed"
                      
    messageEncoding="Mtom"
                     
    maxReceivedMessageSize="67108864" maxBufferSize="65536"
                     
    closeTimeout="00:01:00" openTimeout="00:01:00"
                     
    receiveTimeout="00:10:00" sendTimeout="00:01:00">
    <readerQuotas maxDepth="32" maxStringContentLength="67108864" maxArrayLength="67108864" maxBytesPerRead="67108864" maxNameTableCharCount="67108864" /> <security mode="None">
               
    <transport clientCredentialType="None" />
             
    </security>
    </binding> </basicHttpBinding>

    Then when hosting the WCF Service in the IIS, please also try to add the following in the config file as well:

    <system.web>
    
        <httpRuntime executionTimeout="4800" maxRequestLength="500000000"/>
    </system.web>
    
    <system.webServer>
            <security>
                <requestFiltering>
                    <requestLimits maxAllowedContentLength="500000000"></requestLimits>
                </requestFiltering>
            </security>
    </system.webServer>

    Best Regards,
    Amy Peng



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, August 5, 2014 5:24 AM
    Moderator
  • Thanks Amy,

    After fixed app.config and web.config, now I'm got this error, what's I need to do now???

    "The remote server returned an error: (415) Cannot process the message because the content type 'multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:4fdd9245-41dd-49a2-a65d-3efc1cf86a49+id=1";start-info="text/xml"' was not the expected type 'text/xml; charset=utf-8'.."

    Tuesday, August 12, 2014 2:25 AM