简体   繁体   中英

(413) Request Entity Too Large error with 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.

您需要为您的服务以及客户端(这是您现在获得的)绑定配置,您可以在其中定义最大大小,否则默认为64 kb。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM