为什么使用HttpPost登录网站会再次显示登录页面?

时间:2012-04-12 18:52:10

标签: android http-post

我正在开发Android应用,我需要登录网页。为此,我使用HttpPost。这就是我在做的事情:

HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://202.163.117.123:8080/hitrack/default.aspx");
 try {
      // Add your data
      List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
      nameValuePairs.add(new BasicNameValuePair("__EVENTTARGET", ""));
      nameValuePairs.add(new BasicNameValuePair("__EVENTARGUMENT", ""));
      nameValuePairs.add(new BasicNameValuePair("username", "user123"));
      nameValuePairs.add(new BasicNameValuePair("Password", "pass456"));
      nameValuePairs.add(new BasicNameValuePair("ButtonLogin0", "Login"));
      httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8));
      // Execute HTTP Post Request
      HttpResponse response = httpclient.execute(httppost);
      String responseBody = EntityUtils.toString(response.getEntity());
      Log.d("response",responseBody);

  } catch (ClientProtocolException e) {
      // TODO Auto-generated catch block
     e.printStackTrace();
  } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }

但是这显示了同一个loginPage的来源。为什么不重定向到其他页面?我是否必须添加重定向处理程序。如果是,那么我可以实施吗?

我试过了,但这也行不通。

0 个答案:

没有答案