我已经尝试了所有编码选项,如“HttpClient”,“WebClient”等
例如:
public string MakeWebRequest(string url)
{
try
{
string responseContent;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + token);
request.Proxy = GlobalProxySelection.GetEmptyWebProxy(); // null;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (Stream responseStream = response.GetResponseStream())
{
using (StreamReader sr = new StreamReader(responseStream))
responseContent = sr.ReadToEnd();
}
}
return responseContent;
}
catch (Exception ex)
{
return ex.Message;
}
}
我尝试使用Windows Phone App中的相同代码,它可以在1/10的时间内完成。控制台应用,结果相同。我在许多设备上也尝试过它但没有成功。
所有其他请求都运作良好。
我该如何解决?