Will the Sharp Architecture ModelBinder properly constitute an object using a jQuery ajax request?

160 Views Asked by At

Do you know if it's possible to make an AJAX request and have the model binder properly constitute an object based on the parameter provided?

For example:

$.ajax({
    type: 'POST',
    url: '../Create',
    data: ( {
        'SkillTypeRequest.Id':                0,
        'SkillTypeRequest.Event.Id':        eventId,
        'SkillTypeRequest.SkillType.Id':    skillTypeId,
        'SkillTypeRequest.Division.Id':     divisionId
    } ),
    success: function (data) { addSkillTypeRow( data ); }
});

The test controller action is:

public ActionResult Create(SkillTypeRequest request) { return Json( request ); }

At the moment, this fails in the model binder because it's trying to assign null to the SkillTypeRequest.Id. Before I investigate further, just want to make sure this is even possible to begin with or does Sharp/MVC only allow this type of binding through forms?

0

There are 0 best solutions below