Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc RestSharp序列化程序设置程序无效_Asp.net Mvc_Json_Json.net_Restsharp - Fatal编程技术网

Asp.net mvc RestSharp序列化程序设置程序无效

Asp.net mvc RestSharp序列化程序设置程序无效,asp.net-mvc,json,json.net,restsharp,Asp.net Mvc,Json,Json.net,Restsharp,我正在努力用EF4与MVCAPI进行RestSharp对话,我很快就能让它工作了。为了克服股票序列化程序的接口限制,我使用Json.NET序列化程序。对于反序列化,它是开箱即用的,但我不能让RestSharp使用我的自定义序列化程序。未调用方法Serialize。一切都很好,但不起作用。代码如下: var client = CreateClient(); // client.Authenticator = new HttpBasicAuthenticator(username, password

我正在努力用EF4与MVCAPI进行RestSharp对话,我很快就能让它工作了。为了克服股票序列化程序的接口限制,我使用Json.NET序列化程序。对于反序列化,它是开箱即用的,但我不能让RestSharp使用我的自定义序列化程序。未调用方法
Serialize
。一切都很好,但不起作用。代码如下:

var client = CreateClient();
// client.Authenticator = new HttpBasicAuthenticator(username, password);
var request = new RestRequest("api/{type}s", Method.GET);
request.AddUrlSegment("type", typeof(T).Name);
request.RequestFormat = DataFormat.Json;
request.AddParameter("criteria", criteria);
IRestResponse<List<T>> response = client.Execute<List<T>>(request);
HandleResponse(response);
return response.Data;
但更有趣的是内在的例外:

Error converting value "System.Collections.Generic.List`1[DataAbstractionLayer.Poco.ItemCheckpoint]" to type 'System.Collections.Generic.ICollection`1[DataAbstractionLayer.Poco.ItemCheckpoint]'.
Could not cast or convert from System.String to System.Collections.Generic.ICollection`1[DataAbstractionLayer.Poco.ItemCheckpoint].
是否Json.NET会自动将集合项转换为字符串