Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(413) Request Entity Too Large error with WCF

Tags:

c#

iis

wcf

I'm trying to build a WCF service which will allow users to upload a file, files will be limited to max size of 2mb. I'm passing a byte[] over to the service, but keep getting the following error: System.Net.WebException: The remote server returned an error: (413) Request Entity Too Large.

I'm able to send over files of 1kb and 10kb, but when i try larger ones like 82kb, i get that error. I've looked through some previous posts but can't seem to locate what i'm doing wrong, i've tried to adjust the setting in my config as well, setting max values to see if that would help, but nothing is working so far. can someone look at what i have and see if i'm missing something, or is this something related to IIS (7.5) not my web.config?

Also this is not using SSL.

WCF config:

  

    <services>
    <service name="DSLDService.DSLDService">
    <endpoint binding="basicHttpBinding" bindingConfiguration=""
    contract="DSLDService.IDocument" />
    </service>
    </services>
  

Web Application config:

  

    <endpoint address="http://xxx/DSLDService/DSLDService.svc"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDocument"
    contract="DSLDServiceReference.IDocument" name="" />
  

and

  

    <binding name="BasicHttpBinding_IDocument" closeTimeout="00:01:00"
    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
    allowCookies="false" bypassProxyOnLocal="false" maxBufferPoolSize="2147483647"    maxBufferSize="2147483647"
    maxReceivedMessageSize="2147483647" useDefaultWebProxy="true">
    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
    </binding>
  

Thanks.

like image 529
Paritosh Avatar asked Jul 13 '26 06:07

Paritosh


1 Answers

You need a binding configuration for you service as well as the client (which is what you got right now), where you define the max sizes otherwise its defaulted to 64 kb.

like image 67
Tommy Grovnes Avatar answered Jul 15 '26 22:07

Tommy Grovnes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!