C#发送 http请求
2014-01-12 18:15
363 查看
string url = "http://php.weather.sina.com.cn/xml.php?city=" + HttpUtility.UrlEncode("遂宁", Encoding.GetEncoding("GB2312")) + "&password=DJOYnieT8234jlsK&day=0";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "Get"; //Get or Post
req.ContentType = "application/x-www-form-urlencoded";
HttpWebResponse rep = (HttpWebResponse)req.GetResponse();
//获取流
using (Stream receiveStream = rep.GetResponseStream())
{
}
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "Get"; //Get or Post
req.ContentType = "application/x-www-form-urlencoded";
HttpWebResponse rep = (HttpWebResponse)req.GetResponse();
//获取流
using (Stream receiveStream = rep.GetResponseStream())
{
}
string url = "http://php.weather.sina.com.cn/xml.php?city=" + HttpUtility.UrlEncode("遂宁", Encoding.GetEncoding("GB2312")) + "&password=DJOYnieT8234jlsK&day=0"; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.Method = "Get"; //Get or Post req.ContentType = "application/x-www-form-urlencoded"; HttpWebResponse rep = (HttpWebResponse)req.GetResponse(); //获取流 using (Stream receiveStream = rep.GetResponseStream()) { }
string url = "http://www.fm418.com/UploadFile/book2013122311513570622.mp3";//url HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);//创建请求 req.Method = "Get"; //Get or Post req.Accept = "application/json, text/javascript, */*; q=0.01";//请求信息 req.ContentType = "application/json; charset=UTF-8"; string param = "{id:" + txtId.Text + ",uid:" + txtUid.Text + "}"; //设置参数 using (Stream stream = req.GetRequestStream()) //把参数添加进去 { byte[] buf = Encoding.UTF8.GetBytes(param); stream.Write(buf, 0, buf.Length); } HttpWebResponse rep = (HttpWebResponse)req.GetResponse(); //返回对象 //获取流 using (Stream receiveStream = rep.GetResponseStream()) { }
相关文章推荐
- C# 发送Http请求 - WebClient类
- C#语言Windows服务程序测试网站发送HTTP请求超时解决办法
- C#后台发送HTTP请求
- C#发送Post方式的Http请求
- 使用C#发送Http请求实现模拟登陆实例
- c#发送Http请求
- 使用C#发送Http请求实现模拟登陆实例
- c# 使用HttpWebRequest发送http请求
- C#通过GET/POST方式发送Http请求
- c#发送http请求
- C#发送HTTP请求
- C#调用微博api发送带图片微博,模拟http请求
- C# 发送Http请求 - WebClient类
- C#发送http请求
- C#模拟HTTP请求并发送二进制
- C# 模拟发送Http请求获取请求页面
- C#用SOCKET发送HTTP请求小例
- C# 发送Http请求 - WebClient类
- 在webservice中使用C#发送http请求并获得响应内容
- C#客户端发送Http请求与服务端通信