积极答复者
请问我的程序为什么注册不上去账号

问题
-
HttpWebRequest MyRequest = (HttpWebRequest)WebRequest.Create("http://www.kshr.com.cn/ksasp/main/qsearch.asp"); string str ="username=" + textBox1.Text.Trim() + "&password=" + textBox2.Text.Trim() + "&password1=" + textBox2.Text.Trim() + "&email=" + textBox3.Text.Trim() + "&web=www.sohu.com&name=fiii&address=jiangsu&postcode=299387&phone=13451177399"; string str = "textfield=PE"; MessageBox.Show(str); byte[] Info = Encoding.UTF8.GetBytes(str); MyRequest.Method = "POST"; MyRequest.ContentType ="application/x-www-form-urlencoded"; MyRequest.ContentLength = Info.Length; using (Stream stream = MyRequest.GetRequestStream()) { stream.Write(Info, 0, Info.Length); HttpWebResponse MyResponse = (HttpWebResponse)MyRequest.GetResponse(); StreamReader sr = new StreamReader(MyResponse.GetResponseStream(), Encoding.Default); string re = sr.ReadToEnd(); webBrowser1.DocumentText = re;
如上代码,我从网站上看到是Post到本身网页的,可是怎么弄都注册不上,请达人指教.谢谢!
答案
-
webbrowser端没有session的概念,只有cookie,你把cookie送过去就行了
霸王- 已标记为答案 xuzhiqiang 2010年3月15日 0:41
全部回复
-
SORRY第二个STR是我测试用的,前面应该有个//来删除点,string str = "textfield=PE";这句是查询的,可以实现,但注册不行URL是http://www.kshr.com.cn/ksasp/person/regist.asp。
HttpWebRequest MyRequest = (HttpWebRequest)WebRequest.Create("http://www.kshr.com.cn/ksasp/person/regist.asp");
string str ="username=" + textBox1.Text.Trim() + "&password=" + textBox2.Text.Trim() + "&password1=" + textBox2.Text.Trim() + "&email=" + textBox3.Text.Trim() + "&web=www.sohu.com&name=fiii&address=jiangsu&postcode=299387&phone=13451177399";
MessageBox.Show(str);
byte[] Info = Encoding.UTF8.GetBytes(str);
MyRequest.Method = "POST";
MyRequest.ContentType ="application/x-www-form-urlencoded";
MyRequest.ContentLength = Info.Length;
using (Stream stream = MyRequest.GetRequestStream())
{
stream.Write(Info, 0, Info.Length);
HttpWebResponse MyResponse = (HttpWebResponse)MyRequest.GetResponse();
StreamReader sr = new StreamReader(MyResponse.GetResponseStream(), Encoding.Default);
string re = sr.ReadToEnd();
webBrowser1.DocumentText = re; -
webbrowser端没有session的概念,只有cookie,你把cookie送过去就行了
霸王- 已标记为答案 xuzhiqiang 2010年3月15日 0:41