Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java asp.net对象已移动_Java_Asp.net_Http Post - Fatal编程技术网

Java asp.net对象已移动

Java asp.net对象已移动,java,asp.net,http-post,Java,Asp.net,Http Post,这是一个HTML表单 String parameters = "__VIEWSTATE=" + "__EVENTTARGET=" + "__EVENTARGUMENT=" + "&ctl00$tbUsername=" + URLEncoder.encode("name", "UTF-8") + "&ctl00$tbPwd=" + URLEncoder.encode("pssw", "U

这是一个HTML表单

String parameters = "__VIEWSTATE=" + "__EVENTTARGET="
                + "__EVENTARGUMENT=" + "&ctl00$tbUsername="
                + URLEncoder.encode("name", "UTF-8") + "&ctl00$tbPwd="
                + URLEncoder.encode("pssw", "UTF-8")
                + "&ctl00$chkRememberLogin=" + URLEncoder.encode("0", "UTF-8")
                + "&ctl00$cmdLogin=" + URLEncoder.encode("Login", "UTF-8");
    URL url;
    HttpURLConnection connection = null;
    try {
        url = new URL("www.website.com/Login.aspx");
        connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-Type",
                "text/html; charset=utf-8");
        connection.setRequestProperty("Content-Length",
                "" + Integer.toString(parameters.getBytes().length));
//trying everything..
        connection.setDefaultUseCaches(true);
        connection.setUseCaches(true);

        connection.setUseCaches(true);
        connection.setDoInput(true);
        connection.setDoOutput(true);
        connection.setAllowUserInteraction(true);
        connection.setInstanceFollowRedirects(true);
        HttpURLConnection.setFollowRedirects(true);

        DataOutputStream wr = new DataOutputStream(
                connection.getOutputStream());
        wr.writeBytes(parameters);
        wr.flush();
        wr.close();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (connection != null) {
            connection.disconnect();
        }

    }
}

用户名:
密码:

记住我
回复消息是:“对象移动到此处”。#%^#%^?!有人能解释一下可能的错误吗。。。WireShark显示来自客户端和浏览器的相同post请求


另外,知道的人,请帮助。

据我所知,您尝试通过post发送姓名和密码,您会收到重定向消息!从网页上说,让你阅读不同的位置

这是因为

  • 您尝试了一个不安全的页面,服务器将您重定向到一个安全的SSL
  • 发布后,服务器继续处理数据,并通过重定向到新页面进行响应

  • 据我所知,您尝试通过post发送姓名和密码,您会收到一条重定向消息!从网页上说,让你阅读不同的位置

    这是因为

  • 您尝试了一个不安全的页面,服务器将您重定向到一个安全的SSL
  • 发布后,服务器继续处理数据,并通过重定向到新页面进行响应

  • 我不明白这个问题。HTML表单有效吗?是的,HTML表单有效,问题是我可能使用了错误的方法将数据发布到服务。我不理解这个问题。HTML表单有效吗?是的,HTML表单有效,问题是我可能使用了错误的方法将数据发布到服务。你完全理解它。当我尝试使用另一种方法进行post时,我只得到了我想要发布的页面,没有值。第二种情况:当服务器重定向时,不应该连接。followredirects(true)解决了这个问题?SSL中是否有其他授权方法?@Mocialov followredirect可能可以解决这个问题,但实际上没有问题-您只需要得到一个需要响应的响应。另外,当我收到此“对象移动”消息时,链接类似于:www.website.com/Login.aspx?aspxAutoDetectCookiesSupport=1,我假设服务器希望我从中启用Cookie。。还是错了?我应该自己重新定向请求吗?你完全理解。当我尝试使用另一种方法进行post时,我只得到了我想要发布的页面,没有值。第二种情况:当服务器重定向时,不应该连接。followredirects(true)解决了这个问题?SSL中是否有其他授权方法?@Mocialov followredirect可能可以解决这个问题,但实际上没有问题-您只需要得到一个需要响应的响应。另外,当我收到此“对象移动”消息时,链接类似于:www.website.com/Login.aspx?aspxAutoDetectCookiesSupport=1,我假设服务器希望我从中启用Cookie。。还是错了?我应该自己重定向请求吗?
    <form id="LoginForm" name="LoginForm" method="post" action="Login.aspx?__ufps=747201&loggedout">
    <input type="hidden" name="__VIEWSTATE" value="/wEXAQUDX19QD2QPBirKUk9SFs6IZg==">
    <input type="hidden" name="__EVENTTARGET" value="">
    <input type="hidden" name="__EVENTARGUMENT" value="">
    <script language=javascript><!--
    function __doPostBack(target, argument){
      var theform = document.LoginForm
      theform.__EVENTTARGET.value = target
      theform.__EVENTARGUMENT.value = argument
      theform.submit()
    }
    // -->
    </script>
    
    <div nowrap><b>Username:</b></div><input name="ctl00$tbUsername" /><br>
    <b>Password:</b><br>
    <input name="ctl00$tbPwd" type="password"/><br>
    <input type="checkbox" name="ctl00$chkRememberLogin" value="0" checked>Remember Me<br>
    <input name="ctl00$cmdLogin" type="submit" value="Login"/>&nbsp;
                            <input name="ctl00$cmdForgetMe" type="submit" value="Forget Me"/>
    </form>