We are using KO.JS for data binding where we have observable array. We use Ajax Jquery Post to post the data on to server.
For some reason the array from JSON is not being converted on to c# List. We get NULL.
Below is the snipped, could someone please help?
var removedIds = [];
for (var rsId in RemovedSchoolIds()) {
removedScIds.push(inputForm.schoollViewModel.RemovedSchoolIds());
}
removedScIds = removedScIds.join();
var teacherDetails = {
FirstName: inputForm.formDetails.firstName(),
LastName: inputForm.formDetails.lastName(),
RemoveFromSchools: removedIds.toString()
};
dataService.UpdateTeacher(teacherDetails);
Data Service has UpdateTeacher which has:
$.ajax({
type: "POST",
url: service/update,
data: $.param(data),
dataType: 'json',
timeout: timeout
})
.done(successfulCallback)
.fail(unsuccessfulCallback)
.always(alwaysCallback);
And Finally C#:
[HttpPost]
public virtual ActionResult Update(TeacherDetails teacherDetails)
public class TeacherDetails
{
/// <summary>
/// Guid array for remove schools.
/// </summary>
public IEnumerable<Guid> RemoveFromSchools { get; set; }
}
Also on what type of scenario do we use json.stringnify?