Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i make WCF service on server side to upload file and insert to database.but,i find a problem..when i upload file from desktop app (call that WCF Service),it's say The remote server returned an unexpected response: (413) Request Entity Too Large..i have found the solution from internet and they say to increase values of uploadreadaheadsize, request filtering, maxReceivedMessageSize, maxBufferSize, maxbufferpoolsize, etc (in app.config and web.config)..i have tried all of them,but it's same..

here is my web.config
<serverRuntime uploadReadAheadSize="2147483647" />
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483647" />
</requestFiltering>
</security>
</system.webServer>
<system.serviceModel>
<bindings>
<basicHttpBinding>
 
<binding name="basicHttp" allowCookies="true"
maxReceivedMessageSize="2147483647" 
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
transferMode="Streamed"
messageEncoding="Text"
textEncoding="utf-8"
bypassProxyOnLocal="false"
useDefaultWebProxy="true" >
<readerQuotas maxDepth="2147483647" 
maxArrayLength="2147483647"
maxStringContentLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>


here is my app.config
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" allowCookies="false"
bypassProxyOnLocal="false" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647"
maxArrayLength="2147483647"
maxStringContentLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
 
<endpointBehaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>
 
<client>
<endpoint address="http://localhost:3724/Service.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService" contract="ServiceReference1.IService" />
</client>


can you give me solution? i'm very need it..thanks
Posted

1 solution

if the problem isn't on your application but on server application and you you're trying to access an webApplication via WCF, you need to set the maxRequestLength on server application like the same action made on app.config.
http://msdn.microsoft.com/pt-br/library/e1f13641(v=vs.85).aspx

If the exception throws on you WCF application, you need to set the maxReceivedMessageSize on app.config.

SQL
WCF by default limits messages to 64KB to avoid DOS attack with large message. By default, it sends byte[] as base64 encoded string and it increases the size of the message (33% increase in size). There for if the uploaded file size is ~larger than 48KB then it raises the above error. (48KB * 1.33 = ~64KB) (NB. you can use MTOM – Message Transmission Optimization Mechanize to optimize the message)

By modifying the "maxReceivedMessageSize" in the Web.config file to accept large messages, you can solve this issue.


(413) Request Entity Too Large[^]

Best regards,

Leonardo Metre
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900