HttpClient异步调用WEB服务
2015-08-07 15:29
309 查看
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); } } } }
相关文章推荐
- C++ http socket 文件上传和下载 FILE写文件失败
- TCP状态转换图详解
- TCP学习(1)--报文段首部格式
- http和socket之长连接和短连接区别
- python网络爬虫抓取ajax动态网页数据:以抓取KFC门店地址为例
- 协议森林08 不放弃 (TCP协议与流通信)
- http协议理解
- Chocolate 网络流解法
- 使用apache搭建http文件服务器
- 【VMCloud云平台】SCVMM进阶篇(一)网络虚拟化(1)
- Android 网络通信框架Volley简介(Google IO 2013)
- 【linux高级程序设计】(第十六章)网络服务器应用设计
- UNIX网络编程卷一:第五章 TCP客户/服务器程序实例
- tcpdump
- Qt PC 安卓 tcp传输文件
- HDU 5000 Clone (2014年鞍山赛区网络赛D题)
- Http请求之HttpClient + AsyncTask异步请求
- HttpURLConnection 提交表单+ 上传文件
- 完美网络
- 网络请求(一)