title: WCF 400 Bad Request for Large Data
body: <p>I am developing a REST service in .NET 4.0 and here is my web.config file
  I an new to .NET and have been struggling for two days to understand why I am not able to upload data more than ~60KB.</p>
  
  <p>I understood by googling that that the BufferSize has to be increased and tried modifing web.config file in different ways which never worked. Can someone help me. </p>
  
  <p>Regards
  Hitesh</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
   &lt;configuration&gt;   &lt;system.web&gt;
       &lt;compilation debug="true" targetFramework="4.0"&gt;
         &lt;assemblies&gt;
           &lt;add assembly="System.Data.Entity,
   Version=4.0.0.0, Culture=neutral,
   PublicKeyToken=b77a5c561934e089" /&gt;
         &lt;/assemblies&gt;
       &lt;/compilation&gt; &lt;httpRuntime maxRequestLength="1048576"/&gt;  
   &lt;/system.web&gt;   &lt;system.webServer&gt;
       &lt;modules runAllManagedModulesForAllRequests="true"&gt;
         &lt;add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0,
   Culture=neutral,
   PublicKeyToken=b03f5f7f11d50a3a" /&gt;
       &lt;/modules&gt;   &lt;/system.webServer&gt;   &lt;system.serviceModel&gt;
       &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" /&gt;
       &lt;standardEndpoints&gt;
         &lt;webHttpEndpoint&gt;
           &lt;!-- 
               Configure the WCF REST service base address via the
   global.asax.cs file and the default
   endpoint 
               via the attributes on the &lt;standardEndpoint&gt; element below
           --&gt;
           &lt;standardEndpoint name="" helpEnabled="true"
   automaticFormatSelectionEnabled="true"
   /&gt;
         &lt;/webHttpEndpoint&gt;
       &lt;/standardEndpoints&gt; &lt;services&gt;
  
   &lt;service name=""
   behaviorConfiguration="UpdateRealtimeWebPortfolioStructure.Service1Behavior"
   &gt; &lt;!-- Service Endpoints --&gt;
  
   &lt;endpoint address=""
   binding="wsHttpBinding"
   contract="UpdateRealtimeWebPortfolioStructure.IService1"
   bindingConfiguration="higherMessageSize_WS"&gt;&lt;!--
   Upon deployment, the following
   identity element should be removed or
   replaced to reflect the
  
   identity under which the deployed
   service runs. If removed, WCF will
   infer an appropriate identity
  
   automatically.
  
   --&gt; &lt;identity&gt;
  
   &lt;dns value="localhost" /&gt; &lt;/identity&gt;
  
   &lt;/endpoint&gt; &lt;endpoint address="mex"
   binding="mexHttpBinding"
   contract="IMetadataExchange"
   bindingConfiguration="higherMessageSize_MEX"/&gt;
  
   &lt;/service&gt; &lt;/services&gt;
  
   &lt;bindings&gt; &lt;wsHttpBinding&gt;
  
   &lt;binding name="higherMessageSize_WS"
   closeTimeout="10:01:00"
  
   openTimeout="10:01:00"
   receiveTimeout="10:10:00"
   sendTimeout="10:01:00"
  
   bypassProxyOnLocal="false"
   transactionFlow="false"
   hostNameComparisonMode="StrongWildcard"
  
   maxBufferPoolSize="524288000"
   maxReceivedMessageSize="65536000"
   messageEncoding="Text"
  
   textEncoding="utf-8"
   useDefaultWebProxy="true"
   allowCookies="false"&gt;&lt;/binding&gt;
   &lt;/wsHttpBinding&gt;
  
   &lt;mexHttpBinding&gt; &lt;binding
   name="higherMessageSize_MEX" /&gt;
  
   &lt;/mexHttpBinding&gt;
  
  
   &lt;/bindings&gt;&lt;behaviors&gt;
   &lt;serviceBehaviors&gt;
  
   &lt;behavior name=""&gt; &lt;!-- To avoid
   disclosing metadata information, set
   the value below to false and remove
   the metadata endpoint above before
   deployment --&gt;
  
   &lt;serviceMetadata httpGetEnabled="true"
   /&gt; &lt;dataContractSerializer
   maxItemsInObjectGraph="2147483647"/&gt;
  
   &lt;!-- 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 --&gt;
   &lt;serviceDebug
   includeExceptionDetailInFaults="false"
   /&gt;
  
   &lt;/behavior&gt; &lt;/serviceBehaviors&gt;
  
   &lt;/behaviors&gt;   &lt;/system.serviceModel&gt; 
   &lt;connectionStrings&gt;
       &lt;add name="GeoContainer" connectionString="metadata=res://*/Geo.csdl|res://*/Geo.ssdl|res://*/Geo.msl;provider=System.Data.SqlClient;provider
   connection string=&amp;quot;Data
   Source=YQLABSSERVER\SQLEXPRESS;Initial
   Catalog=Geo;Integrated
   Security=True;MultipleActiveResultSets=True&amp;quot;"
   providerName="System.Data.EntityClient"
   /&gt;   
   &lt;/connectionStrings&gt;
   &lt;/configuration&gt;
  </code></pre>