关于C#的HTTPWEBREQUEST问题
2007-09-07 09:04
435 查看
我得不到,我想要的结果,请问这是为什么......请高手解答.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
namespace WindowsApplication8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string mobilenum = textBox1.Text;
string updata = "mobile=" + mobilenum+"&B1=查询";
ASCIIEncoding asc = new ASCIIEncoding();
byte[] data = asc.GetBytes(updata);
HttpWebRequest hwr = (HttpWebRequest)WebRequest.Create("http://www.ip138.com:8080/search.asp");
hwr.ContentType = "application/x-www-form-urlencoded";
hwr.ContentLength = data.Length;
hwr.Method = "POST";
Stream str = hwr.GetRequestStream();
str.Write(data, 0, data.Length);
HttpWebResponse hw = (HttpWebResponse)hwr.GetResponse();
Stream sr = hw.GetResponseStream();
StreamReader streamread = new StreamReader(sr, Encoding.Default);
string message=streamread.ReadToEnd();
this.webBrowser1.DocumentText = message;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
namespace WindowsApplication8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string mobilenum = textBox1.Text;
string updata = "mobile=" + mobilenum+"&B1=查询";
ASCIIEncoding asc = new ASCIIEncoding();
byte[] data = asc.GetBytes(updata);
HttpWebRequest hwr = (HttpWebRequest)WebRequest.Create("http://www.ip138.com:8080/search.asp");
hwr.ContentType = "application/x-www-form-urlencoded";
hwr.ContentLength = data.Length;
hwr.Method = "POST";
Stream str = hwr.GetRequestStream();
str.Write(data, 0, data.Length);
HttpWebResponse hw = (HttpWebResponse)hwr.GetResponse();
Stream sr = hw.GetResponseStream();
StreamReader streamread = new StreamReader(sr, Encoding.Default);
string message=streamread.ReadToEnd();
this.webBrowser1.DocumentText = message;
}
}
}
相关文章推荐
- C# httpwebrequest post 发送的数据 urlencode 问题
- c# WebRequest或HttpWebRequest多线程下载一定要注意到问题
- C#中关于搜狗地图web服务api的httpresponse中回应json中文乱码的问题 Encoding
- Eclipse开发web项目中关于HttpServletRequest包的问题
- C# HttpWebRequest 上传大文件 超时问题
- C# HttpWebRequest 请求 常出现的问题
- 关于C#提交表单post和get的实现 HttpWebRequest 和ttpebeponse
- 求助(十万火急):关于httpwebrequest发送请求绑定ip的问题.
- 关于读取HttpWebRequest获取的服务器返回流的问题总结
- C#使用HttpWebRequest进行HTTP请求发送和接收的一些小结。(新增修复.NET4.0以下关于cookie的bug)
- C#中HttpWebRequest性能问题
- c#2.0中的HttpWebRequest涉及到的CookieContainer有点问题
- 【C# HTTP】HttpWebRequest使用中编码问题
- 关于使用HttpWebRequest和HttpWebResponse时中文乱码问题
- c#通过webrequest请求远程http服务时出现的问题
- c#通过webrequest请求远程http服务时出现的问题
- 问题:HttpWebRequest request post 传参; 结果:好用的C# HttpWebRequest用Post同时提交参数和文件的封装类
- C# 使用HttpWebRequest用Post提交MultiPart数据
- C#实现通过HttpWebRequest发送POST请求实现网站自动登陆
- C#中HttpWebRequest与HttpWebResponse的使用方法