0

我有兴趣为学校系统创建 Java 成绩门户,但在以 ASP.net 表单发布数据时遇到问题。我已将数据重定向到我自己的表单并提交了数据,但由于某种原因,post 数据在成绩服务本身上不起作用。我已经在应用程序中提交了 __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);

当然,我不能提供用户名和密码供您测试(违反县政策),但也许我可以获得有关它为什么不能正常工作的相关信息。

4

0 回答 0