您的位置:首页 > 理论基础 > 计算机网络

关于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;

}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: