C# 发送Http请求 - WebClient类
来源:互联网 发布:mac底部图标删除 编辑:程序博客网 时间:2024/05/03 22:43
WebClient位于System.Net命名空间下,通过这个类可以方便的创建Http请求并获取返回内容。
一、用法1 - DownloadData
string uri = "http://coderzh.cnblogs.com";
WebClient wc = new WebClient();
Console.WriteLine("Sending an HTTP GET request to " + uri);
byte[] bResponse = wc.DownloadData(uri);
string strResponse = Encoding.ASCII.GetString(bResponse);
Console.WriteLine("HTTP response is: ");
Console.WriteLine(strResponse);
二、用法2 - OpenRead
string uri = " http://coderzh.cnblogs.com";
WebClient wc = new WebClient();
Console.WriteLine("Sending an HTTP GET request to " + uri);
Stream st = wc.OpenRead(uri);
StreamReader sr = new StreamReader(st);
string res = sr.ReadToEnd();
sr.Close();
st.Close();
Console.WriteLine("HTTP Response is ");
Console.WriteLine(res);
- C# 发送Http请求 - WebClient类
- C# Http请求(WebClient,HttpWebRequest)
- C#发送HTTP请求
- C#发送 http请求
- C#发送http请求
- WebClient发送POST请求
- WebClient发送POST请求
- Http请求之 WebClient
- C# HttpWebRequest\HttpWebResponse\WebClient发送请求解析json数据
- C#实现http协议通讯类WebClient
- C#后台发送Http请求
- C#后台发送HTTP请求
- C# WebRequest WebClient Post请求
- C#通过Http发送Soap请求
- c#发送http请求get post
- C#发送Post方式的Http请求
- C# Http 发送Post请求实例
- C#通过Http发送Soap请求
- Java获取EL表达式中System.currentTimeMillis() / 1000的值
- Linux设备驱动剖析之SPI(一)
- Linux USB Gadget--设备枚举
- Linux下QT图形界面开发 信号和槽(3)
- ZeroMQ(java)之异步req/rep
- C# 发送Http请求 - WebClient类
- ios Url Encode
- 常用网站整理
- DirectFB代码导读
- python利用cookie跳过验证码登录,直接获取二级页面内容
- 微软Excel 2007 打勾方框/框里打勾
- DB2 db2icrt The host name "xxx" is invalid. Specify a valid host name
- 几种Web3D技术的比较
- 拉丁矩阵 回溯 c java