从android下载时,Asp.net页面无法读取HttpPost数据

时间:2011-06-08 08:00:11

标签: asp.net android

我是Android编程的新手,我尝试将一些登录数据提交给。通过POST方法进行验证的aspx页面,我注意到.aspx页面无法从我的Android应用程序中读取HttpPost数据。我试图将我的数据提交到.asp页面的两件事,该页面能够使用相同的代码读取数据,除了更改其中的URL,以及第二个。我还创建了一个简单的html文件来将数据提交到.aspx页面,看看POST方法数据似乎没问题,所以现在我不知道这里出了什么问题。

      DefaultHttpClient client = new DefaultHttpClient();
      HttpPost httppost = new HttpPost("http://www.mydomain.com/login.aspx");
      httppost.addHeader("Content-type", "application/x-www-form-urlencoded");
      List<BasicNameValuePair> nvps = new ArrayList<BasicNameValuePair>();
      nvps.add(new BasicNameValuePair("strEmail", username));
      nvps.add(new BasicNameValuePair("strPassword", password));
      try {
          UrlEncodedFormEntity p_entity = new UrlEncodedFormEntity(nvps, HTTP.UTF_8);
        httppost.setEntity(p_entity);

        HttpResponse response = client.execute(httppost);
        ........
        ........

aspx页面基本上没什么用,只是通过Request.Form(“strEmail”)和Request.Form(“strPassword”)获取数据,然后将它与数据库进行比较,然后传回XML结果页面。所以任何人都知道那里缺少什么?

1 个答案:

答案 0 :(得分:0)

还需要定义4个nameValuePairs。

eventvalidation 视图状态 login.x login.y

(登录x和y的名称可能不同)

使用类似Tamper Data(Firefox插件)的内容来分析表单帖子。

相关问题