0
我的WebAPI項目上有一個路徑,它接受一個對象作爲輸入ExportPostData
。 ExportPostData
有一個名爲Contract
的「合同」屬性,當我呼叫路由時,它已成功填充。我將[OnDeserialized]
標記添加到Contract
類,現在它總是失敗了反序列化。沒有錯誤拋出,只是Contract
爲空。我不知道如何調試這個,因爲我的OnDeserialized方法甚至沒有被擊中。OnDeserialized for JSON導致對象爲空
ExportPostData
public class ExportPostData
{
public Contract contract { get; set; }
public bool includeSubItems { get; set; }
public string user { get; set; }
public string[] projects { get; set; }
}
合同
public class ZEstimateContract
{
public string _id { get; set; }
public string contractName { get; set; }
public string contractNumber { get; set; }
public string updatedBy { get; set; }
public DateTime updated_at { get; set; }
[OnDeserialized()]
internal void Deserialized()
{
// THIS NEVER GETS HIT
Console.WriteLine("I'm deserialized");
}
}