Json 将对象从Angular Post传递到.Net ASMX

Json 将对象从Angular Post传递到.Net ASMX,json,angularjs,c#-4.0,asmx,Json,Angularjs,C# 4.0,Asmx,我一直试图将一个对象作为Post参数传递给.NET asmx web服务。我可以将int、string等基本类型作为参数传递,但我希望传递整个对象,因为我的类包含很多属性,并且单独传递每个属性非常耗时 我的c#web服务代码是: [WebMethod(EnableSession = true)] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public ContactBLL AddContact(ContactBLL Contact)

我一直试图将一个对象作为Post参数传递给.NET asmx web服务。我可以将int、string等基本类型作为参数传递,但我希望传递整个对象,因为我的类包含很多属性,并且单独传递每个属性非常耗时

我的c#web服务代码是:

[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public ContactBLL AddContact(ContactBLL Contact)
{
   //add contact and return the contact object
}
我在web服务类的顶部添加了以下语句:

[System.Web.Script.Services.ScriptService]
我在web服务中有第二个函数,我在加载页面时调用该函数以获取json ContactBLL对象

[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public ContactBLL GetContact(int ContactID)
{
    //return contact
}
我在工厂中使用以下函数调用asmx web方法:

factory.GetContactInfo=函数(ContactID){
返回$http.post(serviceBase+'GetContact',{ContactID:ContactID}){
返回结果和数据;
});
};
factory.InsertContact=功能(联系人){
返回$http.post(serviceBase+'AddContact',{ContactBLL:Contact})
返回结果和数据;
});

};我已经找到了错误的原因。我在工厂的AddContact函数中传递的是数据类型(ContactBLL),而不是参数的名称(Contact)。正确的代码如下:

factory.InsertContact=函数(联系人){
返回$http.post(serviceBase+'AddContact',{Contact:Contact})
返回结果和数据;
});
};