2
votes

I have a Silverlight application that uses a WCF service that is located in the web project. I have a method in the service that uploads a file to the database in binary format... this all works fine for files up to around 6MB, but when I go over that limit I get the error "The remote server returned an error: NotFound." Which doesn't tell me much.

I have tracing and logging turned on and I get no errors/messages for this. What I figure is that there is a setting for the upload/transfer size, but I don't know where that would be. I've messed around with certain settings in the web.config with no success.

How do I get past this limit?

EDIT: Maybe I should have posted my code in the first place, I have all of the suggested sizes set (and always have had)...

<bindings>
  <basicHttpBinding>
    <binding name="TaskCalendarService.BasicHttpBinding" 
             maxBufferSize="2147483647" 
             maxReceivedMessageSize="2147483647" 
             maxBufferPoolSize="2147483647"
             transferMode="StreamedResponse">
      <readerQuotas maxDepth="2147483647" 
                    maxStringContentLength="2147483647"
                    maxArrayLength="2147483647" 
                    maxBytesPerRead="2147483647"
                    maxNameTableCharCount="2147483647" />
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>

 <behaviors>
  <serviceBehaviors>
    <behavior name="TaskServiceBehavior">
      <serviceMetadata httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

   <service name="TaskCalendarService" 
           behaviorConfiguration="TaskServiceBehavior">
    <endpoint address="" 
              binding="basicHttpBinding" 
              bindingConfiguration="TaskCalendarService.BasicHttpBinding" 
              contract="Pars.Web.TaskCalendarService" />
    <endpoint address="mex" 
              binding="mexHttpsBinding" 
              contract="IMetadataExchange" />
  </service>

As you can now see, everything that I can think of has been set to a large enough size to be able to handle more than 6 MB, but I still get this error.

EDIT: Error

Inner Exception:

{System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound." & vbCrLf & " at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)" & vbCrLf & " at System.Net.Browser.BrowserHttpWebRequest.<>c_DisplayClass5.b_4(Object sendState)" & vbCrLf & " at System.Net.Browser.AsyncHelper.<>c_DisplayClass4.b_1(Object sendState)" & vbCrLf & " --- End of inner exception stack trace ---" & vbCrLf & "
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)" & vbCrLf & " at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)" & vbCrLf & " at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)}

In the pop up error window it also suggests:

InnerException: Check the Response property of the exception to determin why the request failed. InnerException: Check the Status property of the exception to determin why the request failed.

The response property says: {System.NotImplementedException: This property is not implemented by this class." & vbCrLf & " at System.Net.HttpWebResponse.get_Cookies()}

The Status just says: WebExceptionStatus.UnknownError (HttpStatusCode.NotFound)

Stack Trace:

at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)

2
How are you uploading them? With normal Ria services?Graymatter
@Graymatter I wish I could tell you that, but I am new to this WCF stuff and I can't really say if it is normal RIA or not.Barry Franklin
You should try and use something like this: slfileupload.codeplex.com. This will upload the file in blocks.Graymatter
If you would prefer to use WCF services, please look at the message size limits in this post stackoverflow.com/questions/2517234/…Graymatter
@Graymatter The first comment is a nice app and it works great, but it doesn't provide any code for how it is accomplishing what it does, also it doesn't upload to the database which is a requirement. Also, I have to have this stuff built into my app, I am not allowed to use 3rd party stuff - the company won't allow it. The second comment... I have all of my reader quotas and the maxRecievedMessageSize set to 2147483647 (2GB?), so that shouldn't be the issue, I wouldn't think.Barry Franklin

2 Answers

2
votes

If it is timing out, you can update the custombinding. I'll assume you'll have something like this in Web.config:

<bindings>
  <customBinding>
    <binding name="CustomBinding_HelloWorldService">
      <binaryMessageEncoding />
      <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
    </binding>
  </customBinding>
</bindings>

If so, you can update the binding as such (I'm just setting it to 10 minutes here):

<binding name="CustomBinding_HelloWorldService" sendTimeout="00:10:00">

If you want to look into this a bit more: custombinding

2
votes

The solution for your problem is simple because it is made by default value of <httpRuntime maxRequestLength/> which is 4mb i think and as i know it provides information of that how much data can WCF service receive from client in one call. You just have to add this tag in WCF service under tag and it should look like this

<system.web> <compilation debug="true" targetFramework="4.0" /> <httpRuntime maxRequestLength="2000000" /> </system.web>

this example is for 2gb.