Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The remote server returned an error: (413) Request Entity Too Large + WCF

Tags:

wcf

May be this question is a duplicate. I have a WCF upload service through which the client uploads a particular file to the server.

I could successfully send files of size 12MB through the service.

Now I have integrated a self certified SSL certificate to the WCF Service. The same application which was working fine without SSL now returns an error saying Remote server returned an error (413) request entity too large.

how do I fix this error is this something to do with SSL ?

where am I going wrong.

<system.serviceModel>

<bindings>
  <basicHttpBinding>
    <binding name="customHttpBinding" openTimeout="00:10:00" sendTimeout="00:10:00"
     maxReceivedMessageSize="10067108864"
      messageEncoding="Mtom" transferMode="Streamed">          
      <security mode="Transport">
        <transport clientCredentialType="Certificate" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>

<behaviors>
  <serviceBehaviors>
    <behavior name="customServiceBehavior">
      <serviceMetadata httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>

      <serviceCredentials>
        <clientCertificate>
          <authentication certificateValidationMode="PeerOrChainTrust" trustedStoreLocation="LocalMachine"/>
        </clientCertificate>
      </serviceCredentials>

    </behavior>
  </serviceBehaviors>
</behaviors>

<services>
  <service behaviorConfiguration="customServiceBehavior" name="FileTransferService">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="customHttpBinding"
      contract="IFileTransferService" />
  </service>
</services>

thanks

like image 687
Sandeep Srinivas Kulkarni Avatar asked Oct 15 '12 05:10

Sandeep Srinivas Kulkarni


People also ask

What is error 413 (request entity too large)?

If the file size exceeds the limit, the application will throw “ Error in HTTP request, received HTTP status 413 (Request Entity Too Large) ” error. The default file upload size is 49 KB (49152 bytes).

What is request entity too large error in IIS?

Apr 29 2019 02:33 PM IIS has a limit for the size of the files users can upload to an application. If the file size exceeds the limit, the application will throw “ Error in HTTP request, received HTTP status 413 (Request Entity Too Large) ” error.

Can WCF service be used for file upload?

Recently created a WCF Service to be used for file upload. Hope it helps.. Loading... Be the first to like this. I love working in and sharing everything about Microsoft.NET technology !

How to avoid 413 error in service endpoint?

To avoid the 413 error, Do not foreget to Specify the bindingConfiguration="MybasicBinding" for service endpoint as, Show activity on this post.


1 Answers

This seems to be the ticket to fixing the 413 Request Entity too large error with WCF over HTTPS

C:\Windows\System32\inetsrv>appcmd.exe set config "Default Web Site" -section:system.webServer/serverRunTime /uploadReadAheadSize:10485760 /commit:apphost

The reason seems to be related to how IIS handles authentication of incoming requests over SSL.

Another resource: http://blogs.msdn.com/b/jiruss/archive/2007/04/13/http-413-request-entity-too-large-can-t-upload-large-files-using-iis6.aspx

I just spent most of my afternoon tracking this problem down...many other suggestions didn't help me much but this certainly did, so hopefully this will get you fixed up.

like image 122
BLSully Avatar answered Oct 02 '22 18:10

BLSully