c# - WCF Rest 400 bad request image size -


i have searched on , tried solutions nothing seem work me. bad 400 request when uploading image bigger 64k. working stopped working. no code change or change config file well. else affect config file settings ? here config file

<system.web>     <customerrors mode="off"/>     <compilation debug="true" targetframework="4.0" />     <httpruntime maxrequestlength="2147483647"/>   </system.web>   <system.servicemodel>     <services>       <service behaviorconfiguration="webhttpbehavior" name="ezfindwcfservice.ezfindwebservice">         <endpoint address="" behaviorconfiguration="ezfindwcfservice.ezfindwebserviceaspnetajaxbehavior"           binding="webhttpbinding" contract="ezfindwcfservice.ezfindwebservice" />       </service>     </services>     <behaviors>          <endpointbehaviors>         <behavior name="ezfindwcfservice.ezfindwebserviceaspnetajaxbehavior">           <!--<enablewebscript />-->           <webhttp/>         </behavior>       </endpointbehaviors>       <servicebehaviors>         <behavior name="webhttpbehavior">                     <servicemetadata httpgetenabled="true" />           <servicedebug includeexceptiondetailinfaults="true" />           <datacontractserializer maxitemsinobjectgraph="2147483647" />         </behavior>        </servicebehaviors>     </behaviors>     <servicehostingenvironment aspnetcompatibilityenabled="true"       multiplesitebindingsenabled="true" />      <bindings>       <basichttpbinding>         <binding name="webhttpbinding" closetimeout="00:10:00" opentimeout="00:10:00"           receivetimeout="00:10:00" sendtimeout="00:05:00" allowcookies="false"           bypassproxyonlocal="false" hostnamecomparisonmode="strongwildcard"           maxbuffersize="2147483647" maxbufferpoolsize="2147483647" maxreceivedmessagesize="2147483647"           messageencoding="text" textencoding="utf-8" transfermode="buffered"           usedefaultwebproxy="true">           <readerquotas maxdepth="64" maxstringcontentlength="2147483647"             maxarraylength="2147483647" maxbytesperread="2147483647" maxnametablecharcount="2147483647" />           <security mode="none">             <transport clientcredentialtype="none" proxycredentialtype="none"               realm="" />             <message clientcredentialtype="username" algorithmsuite="default" />           </security>         </binding>       </basichttpbinding>     </bindings>    </system.servicemodel> 

in system.servicemodel/services/service set binding "webhttpbinding" don't define bindingconfiguration. problem didn't set webhttpbinding in system.servicemodel/bindings. set basichttpbinding , set name webhttpbinding! in fact complete binding not used, because service-element looks default (because didn't define bindingconfiguration) webhttpbinding , not basichttpbinding name webhttpbinding! reason why upload fails files bigger 64k. because exceed default quota of 64k. hope understand me :) mixing default binding names quite error-prone ;)

update:

this system.servicemodel-section should work:

<services>   <service name="ezfindwcfservice.ezfindwebservice"             behaviorconfiguration="webhttpbehavior" >     <endpoint address=""                binding="webhttpbinding" bindingconfiguration="configwebhttp"               behaviorconfiguration="ezfindwcfservice.ezfindwebserviceaspnetajaxbehavior"               contract="ezfindwcfservice.ezfindwebservice" />   </service> </services>  <behaviors>   <endpointbehaviors>     <behavior name="ezfindwcfservice.ezfindwebserviceaspnetajaxbehavior">       <!--<enablewebscript />-->       <webhttp/>     </behavior>   </endpointbehaviors>   <servicebehaviors>     <behavior name="webhttpbehavior">       <servicemetadata httpgetenabled="true" />       <servicedebug includeexceptiondetailinfaults="true" />       <datacontractserializer maxitemsinobjectgraph="2147483647" />     </behavior>   </servicebehaviors> </behaviors>  <bindings>   <webhttpbinding>     <binding name="configwebhttp"              opentimeout="00:10:00" closetimeout="00:10:00" receivetimeout="00:10:00" sendtimeout="00:05:00"              maxbuffersize="2147483647" maxbufferpoolsize="2147483647" maxreceivedmessagesize="2147483647">       <readerquotas maxdepth="64" maxstringcontentlength="2147483647" maxarraylength="2147483647"                      maxbytesperread="2147483647" maxnametablecharcount="2147483647" />     </binding>   </webhttpbinding> </bindings> 

left out default settings (e.g. binding/security) make config bit more slim. 1 more thing: i'd careful settings quotas int32.maxvalue. may ok testing, keep in mind set values down, when go production.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -