0

Have Breeze setup with WebAPI and EntityFramework.

EntityManager queries working fine. SaveChanges() working fine on all entities, EXCEPT...

I have an entity with an optional related entity:

Public Class Payment
    Public Property Id As Integer
    Public Overridable Property Registree As Registree
    Public Property RegistreeId as Integer?
    Public Property Amount as Double
End Class

Here is my WebAPI action for SaveChanges()

  <HttpPost()>
    Public Function SaveChanges(bundle As JObject) As SaveResult
        Dim result As SaveResult
        Try
            result = breezeDb.SaveChanges(bundle)
        Catch ex As Exception
            Dim err = ex
        End Try
        Return result
    End Function

When I create a new Payment entity in Breeze and call SaveChanges, everything works fine UNLESS my payment entity has a value for RegistreeId.

If RegistreeId has a value, the following happens:

  1. SaveChanges() on the WebAPI is successfully called.
  2. No errors are caught in my Try/Catch.
  3. The "result" returned to the client has no errors associated with it.

However, on client side, the manager.saveChanges() fails, giving an error object with NO details, just "The response had HTTP status code 500."

return manager.saveChanges()
              .then(function(saveResult){
                return saveResult;
              })
              .catch(errorOnSave); //this gets called, no breakpoints get hit in the "then" function

NOTE: The entity IS getting saved correctly to the database, related entity and all. So this is not a foreign key constraint or other database problem.

So it seems something is breaking on the server and no error message is getting to client. But my try/catch is not getting it, and the error ONLY happens if that optional foreign key field is NOT null.

Any ideas?

1 Answer 1

2

Found the problem...didn't realize I had not turned off Custom Errors in web.config.

<system.web>
    <customErrors mode="Off" />
  ...
  </system.web>

Then I was able to see that Json.Net was running into null exception error when parsing the saveresult.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, you saved my day :) I was not able to see the error detail (like you) until I turn Off customErrors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.