using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace HttpClientTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("开始");
GetData();
Console.WriteLine("结束");
Console.ReadKey();
}
private static async void GetData()
{
HttpClient httpClient = new HttpClient();
HttpResponseMessage response = null;
response = await httpClient.GetAsync("http://wcf.open.cnblogs.com/blog/sitehome/recent/10");
if (response.IsSuccessStatusCode)
{
Console.WriteLine("Response Status Code:" + response.StatusCode + " " + response.ReasonPhrase);
string responseBodyAsText = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(responseBodyAsText);
}
}
}
}