vendredi 20 janvier 2017

Model Binding with optional parameter in angular and web api 2

i have a Model in web api

  public class myModel{
public string FirstName{get;set;}
public string LastName{get;set;}
public int Age {get;set;}
}

Web api Controller

public string saveRecord(myModel data){

return data;
}

angular post ....

  function(){
    var obj={
    FirstName:'Robin',
    Age:24
    }

$http.post(myurl,{ obj}).then(function(rp){
alert(rp.data);
}


}

i have passed only two parameter in post.
now i am getting all values is null in response




Aucun commentaire:

Enregistrer un commentaire