Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/338.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.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 post_Java_Asp.net_Android_Postback_Http Post - Fatal编程技术网

来自java的asp.NET post

来自java的asp.NET post,java,asp.net,android,postback,http-post,Java,Asp.net,Android,Postback,Http Post,不知何故,正常的httpPost不会插入我发送的值 以下是html表单: <form id="LoginForm" name="LoginForm" method="post" action="Login.aspx?__ufps=104203&ReturnUrl=%2fsyspower3%2fmobile%2fdefault.aspx&AspxAutoDetectCookieSupport=1"> <input type="hidden" name="__VIE

不知何故,正常的httpPost不会插入我发送的值

以下是html表单:

<form id="LoginForm" name="LoginForm" method="post" action="Login.aspx?__ufps=104203&ReturnUrl=%2fsyspower3%2fmobile%2fdefault.aspx&AspxAutoDetectCookieSupport=1">
<input type="hidden" name="__VIEWSTATE" value="/wEXAQUDX19QD2QPBvUTF2XiFM6IZg==">
<input type="hidden" name="__EVENTTARGET" value="">
<input type="hidden" name="__EVENTARGUMENT" value="">

<br>
<b>Username:</b><br>

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


用户名:

密码:

记住我
这就是我在java中要做的:

HttpPost httppost2 = new HttpPost(
                    "www.website.com/Login.aspx?ReturnUrl=%2fsyspower3%2fmobile%2fdefault.aspx&AspxAutoDetectCookieSupport=1");

            List<NameValuePair> nameValuePairs2 = new ArrayList<NameValuePair>(4);
            nameValuePairs2.add(new BasicNameValuePair("ctl00$tbUsername", "username"));
            nameValuePairs2
                    .add(new BasicNameValuePair("ctl00$tbPwd", "password"));
            nameValuePairs2.add(new BasicNameValuePair("ctl00$chkRememberLogin", "0"));
            nameValuePairs2.add(new BasicNameValuePair("ctl00$cmdLogin", "Login"));
            nameValuePairs2.add(new BasicNameValuePair("ctl00$cmdForgetMe", "Forget Me"));

            httppost2.setEntity(new UrlEncodedFormEntity(nameValuePairs2));

            response = httpclient.execute(httppost2);
            String responseBody4 = EntityUtils.toString(response.getEntity());
            System.out.println(responseBody4);
HttpPost httppost2=新的HttpPost(
“www.website.com/Login.aspx?ReturnUrl=%2fsyspower3%2fmobile%2fdefault.aspx&aspxAutoDetectCookiesSupport=1”);
列表名称ValuePairs2=新的ArrayList(4);
nameValuePairs2.add(新的BasicNameValuePairs(“ctl00$tbUsername”,“username”));
nameValuePairs2
添加(新的BasicNameValuePair(“ctl00$tbPwd”,“密码”);
nameValuePairs2.add(新的BasicNameValuePair(“ctl00$chkremberLogin”,“0”);
nameValuePairs2.add(新的BasicNameValuePair(“ctl00$cmdLogin”,“Login”));
nameValuePairs2.add(新的BasicNameValuePairs(“ctl00$CMDFegtme”,“忘记我”);
setEntity(新的UrlEncodedFormEntity(nameValuePairs2));
response=httpclient.execute(httppost2);
String ResponseBy4=EntityUtils.toString(response.getEntity());
系统输出打印LN(响应BY4);
但是形式没有改变,我的意思是输入中也没有值。。也许这不是解决问题的方法。完成表单提交的另一种方式是什么

编辑: 据我所知,我是否还必须发布u VIEWSTATE、u EEVENTTARGET、EVENTARGUMENT值
当我从wireshark检查Post值时,它们与我从应用程序发布的once相同。。。所以这有点让人困惑。我打赌这是VIEWSTATE值,我必须首先从服务中获取该值,然后在发布帖子时重新使用它

请在
名称值对
对象中添加url参数(?ReturnUrl=%2fsyspower3%2fmobile%2fmobile.aspx&aspxautodetectokiesupport=1”);
),还要确保您指定了正在使用的协议
http://
https://

如果您不了解asp.net下的asp.netweb服务有什么问题,授权类型是IIW为什么我必须将表单操作添加到NameValuePair中?您已经创建了一个http post对象,并且在get和post之间混合了请求数据。这可以d是问题的原因…只需将URL中的参数添加到
列表nameValuePairs;
&事情应该开始工作了。是否有特殊的方法将字符串对象添加到nameValuePairs?不完全是..它只是带有2个参数name和value的常规构造函数init。
NameValuePairName=新的nameValuePairs(“用户名”,“anantha.sharma”);
此处
user_name
是参数的名称,下一个参数是值。是的,这有点帮助,但不是您提到的情况,我的解决方案不同,我将很快发布它