我想在程序里向一个网页提交数据用于登陆,登陆的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;">密&nbsp;&nbsp;码:</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();">
                &nbsp;
                <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>&nbsp;&nbsp;&nbsp; &nbsp;<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进行验证,每次得到的数据都是登陆页面的数据
,怎么都没办法提交上去,各位大侠帮我看看怎么办

解决方案 »

  1.   

    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吗
      

  2.   

    二楼的大哥我用了你的方法,可以提交了,网页转向到了用户管理页面http://user.vikecn.com/home.asp
    但是得到的信息是未登录,是不是webclient提交后没有处理session,而服务器端需要session验证的问题
      

  3.   

    每次提交数据后,response里的cookie需要单独保存下来,下一个请求是,先设置cookie,然后才开始请求,这样session才有效,能登录其他页面。