如何从一个aspx网站中post数据

bushido 2005-05-12 05:49:22
目标网站页面html代码,这是一个登陆页面
<form name="Form1" method="post" action="login.aspx" >
<input name="txtASI:txtText" type="text" maxlength="5" id="txtASI_txtText" />
<input name="txtUserName:txtText" type="text" maxlength="30" id="txtUserName_txtText" />
<input name="txtPassword:txtText" type="password" maxlength="30" id="txtPassword_txtText" />
<input type="submit" name="btnLogin" value="Log-In" id="btnLogin" />
</form>

=========================================
string param =System.Web.HttpUtility.UrlEncode("txtASI:txtText=88883&txtUserName:txtText=spot25&txtPassword:txtText=moneymoney");
string retstr=string.Empty;
this.txtshow.Text = param;
HttpWebRequest testRq = (HttpWebRequest)WebRequest.Create(url1);
CookieContainer cc = new CookieContainer();
testRq.CookieContainer = cc;
HttpWebResponse tessres = (HttpWebResponse)testRq.GetResponse();
StreamReader r = new StreamReader(tessres.GetResponseStream(),Encoding.UTF8);
r.Close();
tessres.Close();
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url1);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.AllowAutoRedirect = true;
req.CookieContainer = cc;
byte[] SomeBytes = null;
SomeBytes = Encoding.UTF8.GetBytes(param.ToString());
req.ContentLength = SomeBytes.Length;
Stream newStream = req.GetRequestStream();
newStream.Write(SomeBytes, 0, SomeBytes.Length);
newStream.Close();
HttpWebResponse res = (HttpWebResponse)req.GetResponse();

可是还是没有得到登陆后的cookie值
...全文
129 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
sandsboy 2005-05-12
  • 打赏
  • 举报
回复
up
LoveCherry 2005-05-12
  • 打赏
  • 举报
回复
http://www.cnblogs.com/lovecherry/archive/2005/04/22/143341.html
lovvver 2005-05-12
  • 打赏
  • 举报
回复
学习学习~
_jfeng 2005-05-12
  • 打赏
  • 举报
回复
ding....

110,537

社区成员

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

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

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