Search code examples
c#wcflarge-filespayload

Getting Exception when trying to upload a big files size


I'm using wshttpbinding for my service

<wsHttpBinding>
            <binding name="wsHttpBinding_Windows" maxBufferPoolSize="9223372036854775807" maxReceivedMessageSize="2147483647">
                <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxStringContentLength="2147483647" maxNameTableCharCount="2147483647"/>
                <security mode="Message">
                    <message clientCredentialType="Windows"/>
                </security>
            </binding>
        </wsHttpBinding>

<behavior name="ServiceBehavior">
                <dataContractSerializer  maxItemsInObjectGraph="6553600"/>
                <serviceThrottling maxConcurrentCalls="2147483647" maxConcurrentInstances="2147483647" maxConcurrentSessions="2147483647"/>
            </behavior>

and when i try to upload a file of 15Mb it throws the EndPointNotFoundException below:

Exception Message:

There was no endpoint listening at "MY SERVICE URL" that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

Exception:

The remote server returned an error: (404) Not Found.

Solution

  • There are (2) settings maxRequestLength and maxAllowedContentLength on the server side in your WCF confgiration that you are going to need to increase in order for this exception to be resolved. In the .config for the WCF service server side make sure to add the following:

    <system.web>
      <!--Increase 'maxRequestLength' to needed value: 100mb (value is in kilobytes)-->
      <httpRuntime maxRequestLength="102400"/>
    </system.web>
    
    <system.webServer>
      <security>
        <requestFiltering>
          <!--Increase 'maxAllowedContentLength' to needed value: 100mb (value is in bytes)-->
          <requestLimits maxAllowedContentLength="104857600" />
        </requestFiltering>
      </security>
    </system.webServer>