与ASP.net表单Android通信

时间:2013-10-05 14:46:20

标签: java android asp.net

我有兴趣为学校系统创建一个Java级门户,但是我在ASP.net表单中发布数据时遇到了问题。我已将数据重定向到我自己的表单并提交数据,但由于某种原因,帖子数据不适用于成绩服务本身。我在应用程序中提交了__VIEWSTATE和__EVENTVALIDATION,但它重定向回登录页面而没有提交数据。有一次,出现了一个ASP.net错误。

//Post Data
HttpPost post = new HttpPost("https://loudoun.gradebook.net/clarity/Gradebook/Logon.aspx?ReturnUrl=%2fclarity%2fGradebook%2f");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("ctl00$ContentPlaceHolder$Username", username.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("ctl00$ContentPlaceHolder$Password", password.getText().toString()));

//ASP Net Values
nameValuePairs.add(new BasicNameValuePair("__EVENTVALIDATION", "/wEWBgKO4ofwAwLnksmgAQKTpbWbDgLB5+KIBAL4xb20BAK20ZqiCS7btK5SrOdsZpByJbSl/e54HnFG"));
nameValuePairs.add(new BasicNameValuePair("__VIEWSTATE", "/wEPDwUJNTkxNzI3MDIzD2QWAmYPZBYCAgMPZBYGAgEPZBYCAgkPZBYCAgEPZBYIAgMPFgIeB1Zpc2libGVoZAIFDxYCHwBoZAIHDxYCHwBoZAIJDxYCHgVzdHlsZQUjdmVydGljYWwtYWxpZ246bWlkZGxlO2Rpc3BsYXk6bm9uZTtkAgMPDxYCHwBoZGQCBQ9kFghmD2QWAgINDxYCHgVjbGFzcwUQc2luZ2xlU2Nob29sTGlzdBYCAgEPZBYCAgEPEGQPFgFmFgEQBQdMb3Vkb3VuBQhQaW5uYWNsZWdkZAICD2QWAgITD2QWAgIBD2QWAgIBDxBkZBYAZAIHDw8WAh4EVGV4dAUmUGlubmFjbGUgR3JhZGVib29rIDIwMTMgQmFjayB0byBTY2hvb2xkZAIIDw8WAh8DBTdDb3B5cmlnaHQgKGMpIDIwMTMgR2xvYmFsU2Nob2xhci4gIEFsbCByaWdodHMgcmVzZXJ2ZWQuZGRkMXxrC8X7aL5DXnqLrWuJLNNSTxY="));

post.setEntity(new UrlEncodedFormEntity(nameValuePairs));

HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(post);
HttpEntity entity = response.getEntity();

String responseText = EntityUtils.toString(entity);

System.out.println(responseText);

当然,我无法提供用于测试的用户名和密码(针对县政策),但也许我可以获得有关其无法正常工作的相关信息。

0 个答案:

没有答案