winform模拟POST登录网页问题

Colin_Zoo 2010-09-19 01:55:02
就是密码输入错误的时候是跳转到错误密码的页面 但是密码输入正确之后确实跳转到主页了 但是还却没有登录进去

代码如下

string code="GBK";
string step = "2";
string lgt = "0";
string strId = txtName.Text;
string strPassword = txtPwd.Text;
string question = "0";
string customquest = "";
string answer = "";
string hideid = "";
string cktime = "31536000";
string submit = "";
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "forward=&jumpurl=http%3A%2F%2Fwww.tphou.com%2Fbbs%2Fmode.php%3Fm%3Do&step=" + step;
postData += ("&lgt="+lgt);
postData += ("&pwuser=" + strId);
postData += ("&pwpwd=" + strPassword);
postData += ("&question=" + question);
postData += ("&customquest=" + customquest);
postData += ("&answer=" + answer);
postData += ("&hideid=" + hideid);
postData += ("&cktime=" + cktime);
postData += ("&submit=" + submit);
byte[] data = encoding.GetBytes(postData);
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://tphou.com/bbs/login.php");
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.GetEncoding(code));
string content = reader.ReadToEnd();
riBox.Text = content;

...全文
244 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
楼主没改我测试账号或邀请码
 只是猜测下。
 在伪造数据正确的前面下
 原网站编码是gb2312的。
 但楼主的Post时和Get时都不一样
 建议楼主全部换下gb2312的(也可做成参数)
 

     1.  string code="GBK";

2. ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "forward=&jumpurl=http%3A%2F%2Fwww.tphou.com%2Fbbs%2Fmode.php%3Fm%3Do&step=" + step;
   。。。。。。
byte[] data = encoding.GetBytes(postData);
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://tphou.com/bbs/login.php");
      。。。。

StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.GetEncoding([color=#FF0000]code))[/color];
string content = reader.ReadToEnd();
riBox.Text = content;

  • 打赏
  • 举报
回复
给个邀请码。我来试试
Colin_Zoo 2010-09-19
  • 打赏
  • 举报
回复
救命啊 谁来救救我。。。要疯掉了
Colin_Zoo 2010-09-19
  • 打赏
  • 举报
回复
没人来哦。。。。

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧