我想用Fiddler检查http流量,但没有捕获任何http流量,我的测试代码:
private static void ByRestSharp()
{
var restClient = new RestClient("https://jsonplaceholder.typicode.com");
var request = new RestRequest("posts", Method.GET);
var response = restClient.Get<List<Post>>(request);
Console.WriteLine("{0} posts return by RestSharp.", response.Data.Count);
}
Run Code Online (Sandbox Code Playgroud)
但是在我改为使用HttpClient之后,Fiddler可以捕获http流量,示例代码:
private static void ByHttpClient()
{
var httpClient = new HttpClient();
using (var req = new HttpRequestMessage(HttpMethod.Get, "https://jsonplaceholder.typicode.com/posts"))
using (var resp = httpClient.SendAsync(req).Result)
{
var json = resp.Content.ReadAsStringAsync().Result;
var users = SimpleJson.SimpleJson.DeserializeObject<List<Post>>(json);
Console.WriteLine("{0} posts return by HttpClient.", users.Count);
}
}
Run Code Online (Sandbox Code Playgroud)
这是RestSharp还是Fiddler的问题?
我遇到了一个问题:在运行基于SQLite提供程序的SubSonic.Examples.SimpleRepo项目时,无法将类型为"System.Int64"的对象转换为类型"System.Int32".
我喜欢表类别列CategoryID的数据类型是' 整数 ',而SQLite中的'整数'将作为Int64返回,同时ClassID中的CategoryID数据类型为int,发生上述错误.
我检查了SubSonic的源代码:\ SubSonic.Core\SQLGeneration\Schema\SQLiteSchema.cs并找到以下代码:
else if (column.IsPrimaryKey && column.DataType == DbType.Int32
|| column.IsPrimaryKey && column.DataType == DbType.Int16
|| column.IsPrimaryKey && column.DataType == DbType.Int64
)
sb.Append(" integer ");
Run Code Online (Sandbox Code Playgroud)
谁能告诉我这些代码的目的?如何解决数据类型转换错误?