怎么向这样的网页提交数据

wuming1805 2009-07-12 11:20:57
我想在程序里向一个网页提交数据用于登陆,登陆的FORM如下
<form name="loginform" method="post" action="http://login.vikecn.com/" style="margin:0">
<input name="action" type="hidden" value="vkchk">
<ul>
<li><font style="font-size:14px;">用户名:</font>
<input name="username" type="text" id="username" value="" maxlength="16" class="inputitem" onFocus="this.className='inputitem2'" onBlur="this.className='inputitem'">
</li>
<li><font style="font-size:14px;">密  码:</font>
<input name="password" type="password" value="" class="inputitem" onFocus="this.className='inputitem2'" onBlur="this.className='inputitem'" maxlength="16">
</li>
<li style="padding-left:10px;">
<input name="dl" type="submit" class="btnzc" style="width:100px" onMouseOver="this.className='btnzcnew'" onMouseOut="this.className='btnzc'" value="登 录" onClick="return dlcheck();">
 
<input name="zc" type="button" class="btnzc" style="width:78px" onMouseOver="this.className='btnzcnew'" onMouseOut="this.className='btnzc'" onClick="location.href='http://www.vikecn.com/Reg.asp'" value="注 册">
</li>
<li style="padding-left:5px;">
<img src="http://www.vikecn.com//images/Img/forget.gif"> <A href="http://www.vikecn.com/forgetpwd.asp">忘记密码?</a>     <img src="http://www.vikecn.com/images/Img/top_002.gif"> <A href="http://help.vikecn.com/vkyiwen.asp">新手常见问题</a>
</li>
</ul>
<input name="tourl" type="hidden" id="tourl" value="http://user.vikecn.com/home.asp">
</form>
dlcheck()只是基本的数据验证,我想用webrequest提交用户名密码到action进行验证,每次得到的数据都是登陆页面的数据
,怎么都没办法提交上去,各位大侠帮我看看怎么办
...全文
110 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
jimh 2009-07-20
  • 打赏
  • 举报
回复
每次提交数据后,response里的cookie需要单独保存下来,下一个请求是,先设置cookie,然后才开始请求,这样session才有效,能登录其他页面。
「已注销」 2009-07-19
  • 打赏
  • 举报
回复
帮顶,学习中
wuming1805 2009-07-12
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 wuyq11 的回复:]
参考
[/Quote]
二楼的大哥我用了你的方法,可以提交了,网页转向到了用户管理页面http://user.vikecn.com/home.asp
但是得到的信息是未登录,是不是webclient提交后没有处理session,而服务器端需要session验证的问题
wuyq11 2009-07-12
  • 打赏
  • 举报
回复
supercpu123 2009-07-12
  • 打赏
  • 举报
回复
HTTP/1.1 302 Object moved
Date: Sun, 12 Jul 2009 05:03:12 GMT
Server: Microsoft-IIS/6.0
Location: http://user.vikecn.com/home.asp
Content-Length: 152
Content-Type: text/html
Set-Cookie: myusername=test; path=/
Set-Cookie: myvikecn=my%5Fshenhe=0&my%5Fbusiness=0&vkuserip=114%2E237%2E137%2E186%2D3%2D12&vkuserid=12485&vkusername=test; domain=vikecn.com; path=/
Cache-control: private

<head><title>Object moved</title></head>
<body><h1>Object Moved</h1>This object may be found <a HREF="http://user.vikecn.com/home.asp">here</a>.</body>
========================================================================
回发的是302 有个Location跳转 看看你的webrequest支持redirect吗

110,571

社区成员

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

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

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