PostAsJsonAsync无法序列化Dictionary中的对象

时间:2015-02-10 10:38:22

标签: c# dictionary

我有几个代码负责将一些数据发布到web api。我正在尝试发布一个字典。但是,在发布请求时,无法序列化关键属性。

有我的代码:

response = await base.HttpClientInstance.PostAsJsonAsync<Dictionary<ItemDto, string>>(url, dummyItems);

有fiddler会话摘要:

Content-Type: application/json; charset=utf-8
Host: debug.foo.foo.com
Content-Length: 78
Expect: 100-continue
Connection: Keep-Alive

{"Foo.Contract.Items.ItemDto":"87a0a711-6ecb-4ef5-9aed-04f7573344e1"}

问题出在哪里,有什么想法吗?

1 个答案:

答案 0 :(得分:0)

乍一看,您需要在ToString实现中覆盖ItemDto ...系统的默认实现只是打印类的名称,例如{{1 }}