我有一些代码负责将一些数据发布到web api。我正在尝试发布词典。但是当请求被发布时,key属性不能被序列化。PostAsJsonAsync无法序列化字典中的对象
有我的代码:
response = await base.HttpClientInstance.PostAsJsonAsync<Dictionary<ItemDto, string>>(url, dummyItems);
有小提琴手会议纪要:
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"}
问题出在哪里,什么想法?
[Serialize Class contains Dictionary member]可能的重复(http://stackoverflow.com/questions/495647/serialize-class-containing-dictionary-member) – VMAtm 2015-02-10 10:40:49
你不能轻易地序列化实现IDictionary的类 – VMAtm 2015-02-10 10:41:09