Locked Request entity too large bug or something else?

  • Tuesday, May 15, 2012 7:44 AM
     
      Has Code

    Hi,

    I am trying to insert to database a file which size is 8Mb, but when executing Save  i am getting the error Below.

    What do you sugest? I did not have that problem with Lightswitch v.1

    Thank you

    RequestEntityTooLarge   
    at System.Data.Services.Client.BaseSaveResult.HandleResponse(RequestInfo requestInfo, HttpStatusCode statusCode, String responseVersion, Func`1 getResponseStream, Boolean throwOnFailure, Version& parsedResponseVersion)
       at System.Data.Services.Client.BatchSaveResult.HandleBatchResponse()

    =====CODE USED TO INSERT FILE

         Private Sub FilesAddNew_Execute()
                Dim f = DataWorkspace.ApplicationData.Files.AddNew
                f.Patient = Patient
    
                Dim fileinfoobj As FileInfo = SelectFile()
                If Not fileinfoobj Is Nothing Then
                    Dim reader = DocumentReader.Create(fileinfoobj)
                    Using reader
                        f.Notes = fileinfoobj.Name
                        f.FileDetail.FileExtension = fileinfoobj.Extension.ToLower
                        f.FileDetail.FileData = reader.ToBinary
                        'Dim document = Me.Documents.AddNew
                        'document.Name = file.Name
                        'document.File = reader.ToBinary
                    End Using
                ElseIf fileinfoobj Is Nothing Then
                    f.Delete()
                End If
                DataWorkspace.ApplicationData.SaveChanges()
                Files.SelectedItem = f
            End Sub
    
            Private Function SelectFile()
                Dim result As FileInfo = Nothing
                Dispatchers.Main.Invoke(
                Sub()
                    Dim dlg = New OpenFileDialog()
                    If dlg.ShowDialog = True Then
                        result = dlg.File
                    End If
                End Sub)
    
                SelectFile = result
            End Function


All Replies

  • Tuesday, May 15, 2012 2:54 PM
     
     Answered Has Code

    Yes, this is an object size issue.

    modify these parts of your web.config file. 

      <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <dataContractSerializer maxItemsInObjectGraph="6553600"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <bindings>
          <webHttpBinding>
            <binding maxReceivedMessageSize="6553600" />
          </webHttpBinding>
        </bindings>
      </system.serviceModel>

    Increase the numbers by a factor of 10 and see what happens

    • Marked As Answer by tsiakk Tuesday, May 15, 2012 5:46 PM
    •  
  • Tuesday, May 15, 2012 5:46 PM
     
     

    Hi and thank you.. that Did solve the problem!