asp.net 对象已移动
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"/>
<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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我了解,您尝试通过帖子发送名称和密码,然后您会收到一条重定向消息!从告诉您要阅读不同位置的网页上。
这是因为
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