asp.net 对象已移动

发布于 2024-11-25 14:06:15 字数 2798 浏览 0 评论 0原文

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();
        }

    }
}

这是一个 HTML 表单

<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>

回复消息是:“对象移至此处”。 #%^#%^?!有人可以解释一下可能出了什么问题吗... WireShark 显示来自客户端和浏览器的相同帖子

请求请知道的人帮帮忙..

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();
        }

    }
}

and here is a HTML form

<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"/> 
                        <input name="ctl00$cmdForgetMe" type="submit" value="Forget Me"/>
</form>

The reply message is: "Object moved to here". #%^#%^?! Can somebody explain what could possibly be wrong... WireShark showing the same post requests from both client and browser

P.S. People who knows, please help..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花开半夏魅人心 2024-12-02 14:06:15

据我了解,您尝试通过帖子发送名称和密码,然后您会收到一条重定向消息!从告诉您要阅读不同位置的网页上。

这是因为

  1. 您尝试了不安全的页面,而服务器将您重定向到安全的 SSL。
  2. 发布后,服务器会处理数据并响应并重定向到新页面。

From what I understand you try to send via post the name and password and you get a redirect message ! from the web page that say to you to read a different location.

This is because of

  1. You try an unsecured page and server redirect you to a secure SSL.
  2. After your post, the server proceed the data and response with a redirect to a new page.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文