C# 为什么HttpClient.GetAsync()缺少部分内容?

C# 为什么HttpClient.GetAsync()缺少部分内容?,c#,.net,wpf,uwp,C#,.net,Wpf,Uwp,Windows.Web.Http.HttpClient和System.Net.Http.HttpClient收到不同的响应 protected override void OnLaunched(LaunchActivatedEventArgs e) { var client = new Windows.Web.Http.HttpClient(); var taskHttpResponse = client.GetAsync(new Uri(@"https://apis.live.

Windows.Web.Http.HttpClient
System.Net.Http.HttpClient
收到不同的响应

protected override void OnLaunched(LaunchActivatedEventArgs e) {
    var client = new Windows.Web.Http.HttpClient();
    var taskHttpResponse = client.GetAsync(new Uri(@"https://apis.live.net/v5.0/me?access_token=abcdefg"));
    Debug.WriteLine(taskHttpResponse.AsTask().Result.Content.ReadAsStringAsync().AsTask().Result);
}


你在开玩笑吗?

你不应该使用
ReadAsStringAsync()。结果
可能会导致UI中的死锁

我将您的代码更改为
等待
,以获得结果


我发现您的代码没有被授权,我使用的
GetStringAsync
将是一个例外。我认为这个api在没有授权的情况下无法使用。

响应应该是相同的。使用相同的输出流编写器(Debug.WriteLine/Console.WriteLine)并查看其行为是否仍然相同。应将括号放在同一行中,请参见或使用中文括号我还是没明白为什么 Console.WriteLine()跟 Debug.WriteLine()结果不一样呢?能加个好友吗?好啊,欢迎加入 网络校园来交流问题,不过我也不知道为什么 Console.WriteLine()用不了哈哈,或者加我的QQ 2844808902QQ:2451099553加你了,关于 Microsoft Live API:难道只能在已跟应用商店关联的 超宽带应用里调用,我觉得返回 401应该是 代币不正确的缘故。看起来是的, 没有给一个正确值你们两个在这里用中文交谈真是可笑。
{
  "error": {
  "code": "request_token_invalid", 
  "message": "The access token isn't valid."    } }
private static void Main() {
    var client = new System.Net.Http.HttpClient();
    var taskHttpResponse = client.GetAsync(new Uri(@"https://apis.live.net/v5.0/me?access_token=abcdefg"));
    Console.WriteLine(taskHttpResponse.Result.Content.ReadAsStringAsync().Result);
}
}  }  "message": "The access token isn't valid."