非常に簡単な質問がありますが、回答が見つかりません。私は複数のフィールドを持つモデルを持っています。例:.NetクライアントからWebApiサーバにモデルを送信
public class BillingInfoViewModel
{
//Distributor Information
public string DistributorName { get; set; }
public string DistributorEmail { get; set; }
public string DistibutorPhone { get; set; }
public CompanyCode CompanyCode { get; set; }
//ECU information
public string EcuName { get; set; }
public string EcuPartNumber { get; set; }
public string EcuProgramName { get; set; }
//Lot of fields
}
サーバーに送信する必要がある情報です。私はそれをどのようにすることができますか?このフィールドを1つずつ送信する必要がありますか?
public void ApiController(string DistributorName, string DistributorEmail, ..othern fields)
私はすべてのオブジェクトを送信する必要がありますか?
public void ApiController(BillingInfoViewModel model)
P.S.
public class BillingController{
public IHttpActionResult Post([FromBody]BillingInfoViewModel model){
// HERE YOU GET THE BillingInfoViewModel obj from the call (in POST)
}
}
はそれが
、JSONとしてこのデータを送信します。 JSONプロパティ名は、モデルクラスBillingInfoViewModelの同じプロパティ名である必要があります。 – Amit
モデル全体をjsonオブジェクトにシリアル化して送信できます。 –