无法通过POST登录

时间:2015-06-29 11:24:20

标签: c# authentication post

我正在处理C# WinForms app,它连接到网页,登录并获取一些数据。

我没有成功登录部分 - 我在这里阅读了数十篇文章,但没有任何作用。

我尝试访问的页面是基于ASP.NET的。除此之外,我是网络开发的新手。

登录页面的大量代码:

<form action="/User/Login" id="LoginForm" method="post"><input id="returnUrl" name="returnUrl" type="hidden" value="/">
    <td>
      <input id="login" name="login" style="width:150px;" type="text" value="" />
    </td>
    <td>
      <input id="pass" name="pass" style="width:150px;" type="password">
    </td>

并提交:

<span class="ButtonWrap">
    <a href="javascript:submit();" class="ButtonGreen">Login</a>
</span>
<input type="submit">

从我阅读并尝试的所有文章中,我可以连接到页面和POST登录数据,但响应总是相同的 - 我重定向的登录页面。

来自我的计划的C#代码:

var response = Http.Post("...desired web page...", new System.Collections.Specialized.NameValueCollection() {
    { "login", "loginData" },
    { "heslo", "passData" }
});
public static class Http
{
    public static byte[] Post(string uri, System.Collections.Specialized.NameValueCollection pairs)
    {
         byte[] response = null;
         using (WebClient client = new WebClient())
         {
             response = client.UploadValues(uri, "POST", pairs);
         }
         return response;
    }
 }

有人可以帮助我或导航,有什​​么不对吗?

0 个答案:

没有答案
相关问题