HttpClientHandler
2016-01-21 11:36
453 查看
string url = "http://";
//创建HttpClient(注意传入HttpClientHandler)
var handler = new HttpClientHandler() { AutomaticDecompression = System.Net.DecompressionMethods.None };//.GZip };
using (var http = new HttpClient(handler))
{
var response = http.GetAsync(url).Result;
if (response.IsSuccessStatusCode)
return response.Content.ReadAsStringAsync().Result.Replace("\"", "");
else
throw new Exception("Error");
}
//创建HttpClient(注意传入HttpClientHandler)
var handler = new HttpClientHandler() { AutomaticDecompression = System.Net.DecompressionMethods.None };//.GZip };
using (var http = new HttpClient(handler))
{
var response = http.GetAsync(url).Result;
if (response.IsSuccessStatusCode)
return response.Content.ReadAsStringAsync().Result.Replace("\"", "");
else
throw new Exception("Error");
}
相关文章推荐
- 解决UDP丢包问题的经验
- iOS TCP三次握手过程 有意思的解释
- https原理及tomcat配置https方法
- HttpClient支持使用代理服务器以及身份认证
- HttpClient支持使用代理服务器以及身份认证
- Tcpdump 的用法
- TCP通信的基本流程
- [转]【HTTP】Fiddler(二) - 使用Fiddler做抓包分析
- 使用Service和BroadcastReceiver实时监听网络状态
- 新版Matlab中神经网络训练函数Newff的使用方法
- java 发送 http 请求
- HTTP四种常见的POST提交数据方式
- 网络图片转为bitmap 转换为文件(File)保存至SD卡中
- POJ 1087 A Plug for UNIX(Dinic)
- HTTPS
- 使用check_tcp来监测端口是否通
- 判断当前网络是否可用
- ionic将ionicLoading与http请求绑定
- Android访问网络,使用HttpURLConnection还是HttpClient
- 配置ntpd提供网络授时服务