0

I have wcf application, which accept base64 image. It works fine for content length approx upto 69000. Content lentgh more than 69K throw error. Content length get it from fiddler.

An exception of type 'System.ServiceModel.ProtocolException' occurred in mscorlib.dll but was not handled in user code

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

Service Web.config

<system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" maxRequestLength="2097152"/>
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="userServiceBasicHttp" maxBufferPoolSize="2097152" maxReceivedMessageSize="2097152">
          <readerQuotas maxDepth="2097152" maxStringContentLength="2097152" maxArrayLength="2097152" maxBytesPerRead="2097152" maxNameTableCharCount="2097152" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <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>
      <endpointBehaviors>
        <behavior name="customQuotaBehavior">
          <dataContractSerializer maxItemsInObjectGraph="2097152"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <services>
      <service name="ServiceApplication.UserManagement">
        <endpoint behaviorConfiguration="customQuotaBehavior"  address="" binding="basicHttpBinding" bindingConfiguration="userServiceBasicHttp" contract="Contract.User.IUserManagementContract"></endpoint>
      </service>
    </services>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>

Client Web.config

<system.serviceModel>
    <bindings>
      <basicHttpBinding> 
        <binding name="BasicHttpBinding_IUserManagementContract"  maxBufferPoolSize="2097152" maxReceivedMessageSize="2097152">
          <readerQuotas maxDepth="999" maxStringContentLength="2097152" maxArrayLength="2097152" maxBytesPerRead="2097152" maxNameTableCharCount="2097152" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="customQuotaBehavior">
          <dataContractSerializer maxItemsInObjectGraph="2097152"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <client>
      <endpoint behaviorConfiguration="customQuotaBehavior" address="http://localhost:3479/UserManagementService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUserManagementContract"
        contract="UserManagementServiceReference.IUserManagementContract"
        name="BasicHttpBinding_IUserManagementContract" />
    </client>

  </system.serviceModel>

Ajax Call

 $.ajax({
            type:"POST",
            url: "http://localhost:2583/ApplicationManagement/SaveProfilePhoto",
            data: { 'base64Photo': vData },
            success: function (result) { alert(result); }

        });

Client Method

public string SaveProfilePhoto(string base64Photo)
        {

            UserManagementContractClient client = new UserManagementContractClient();

            string userid = "someuserid";
    //userid -- string
    //PictureType --enum
    //base64Photo --string
            client.UpdateUserPhoto(userid, PictureType.UserPhoto,base64Photo);
            return client.GetImage(userid, PictureType.UserPhoto);
        }
vikrantx
  • 593
  • 5
  • 22
  • Maybe http://msdn.microsoft.com/en-us/library/bb763183(v=vs.110).aspx – L.B Aug 28 '14 at 10:17
  • Some worked solutions here - http://stackoverflow.com/questions/10122957/iis7-413-request-entity-too-large-uploadreadaheadsize – Flowerking Aug 28 '14 at 10:31

0 Answers0