1

How do I debug why MVC is returning 500 error when I try to post to my controller from AngularJS? No exceptions are thrown.

Here is my AngularJS code

var recordingRequest = {
    deviceSerial: 2160563840, 
    plannedStartTime: "2015-08-07T14:29", 
    recordingDuration: 60, 
    recordingDurationIsMinutes: true
}

The service that posts the data:

deviceAPI.addDeviceRecording = function (recordingRequest) {
    // Request data
    return $http.post("/devices/adddevicerecording/", recordingRequest);
}

And finally the MVC controller entry point:

[HttpPost]
public ActionResult AddDeviceRecording(int deviceSerial, string plannedStartTime, int recordingDuration, bool recordingDurationIsMinutes)
{
}

Any breakpoints I put inside the AddDeviceRecording function never gets hit. I know its getting part way there because it gives 500 rather than 404. If I change the $http.post to point to a random URL I get 404 instead.

2
  • 1
    your device serial is too high. the max value for ints in C# is 2,147,483,647, your device serial is 2,160,563,840. You need to change your datatypes. Commented Aug 7, 2015 at 13:36
  • 1
    I feel stupid now, thank you ! Please post as an answer so that I can accept - I do wish MVC provided you with some inclining as to why it cannot serialize JSON into POCOs etc Commented Aug 7, 2015 at 13:37

1 Answer 1

2

Your device serial is too high.

the max value for Int32 in C# is 2,147,483,647, your device serial is 2,160,563,840.

You need to change your datatypes

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

Comments

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.