老实说,我不确定有什么问题,它似乎没有通过httpclient发送任何请求。也许我构造的请求不正确(我习惯于使用httpwebrequest)
private static void Main(string[] args)
{
Run();
}
static async void Run()
{
Console.Write("Result started!");
string page = "http://en.wikipedia.org/";
using (HttpClient client = new HttpClient())
using (HttpResponseMessage response = await client.GetAsync(page))
using (HttpContent content = response.Content)
{
string result = await content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
从字面上看,这是我在此特定阶段要实现的全部目标,因为我对使用httpwebrequests最初编写的内容进行了全面的比较,但是没有用。不行吗我想我错过了什么。