现在需要用Java向IIS服务器的某个aspx页面发出一个HTTP的请求,采用POST方式,里面带两个参数(用户名、密码)然后在aspx页面的后台类中取出参数,能否实现。Request请求要求和以下HTML提交的请求一致。
<form action="http://localhost/test/example.aspx" method="POST">
<input type="text" size="10" value="username" name="username">
<input type="text" size="10" value="password" name="password">
<input type=submit value="POST方式">
</form>

解决方案 »

  1.   

    <html>
    <body>
    <form name="ctrl2" method="POST" action="MyLinkButton.aspx" id="ctrl2">
    <input type="hidden" name="__EVENTTARGET" value="" />
    <input type="hidden" name="__EVENTARGUMENT" value="" />
    <input type="hidden" name="__VIEWSTATE" value="dDwtMjI1NTgwNDE2Ozs+eIZ+AfRvoCj1nWimbh+zPv/rKNg=" />                  
    Here is the custom link button.<br>
    <a  id ="Link" href="javascript:__doPostBack('Link','')"> Link</a> 
    <br><br>
    <input name="TextBox" type="text" value="Click the link" id="TextBox" style="background-color:Cyan;width:200px;" /> 
    <br>                                                
    <script language="javascript">
    <!--
          function __doPostBack(eventTarget, eventArgument) {
                var theform = document.ctrl2
                theform.__EVENTTARGET.value = eventTarget
                theform.__EVENTARGUMENT.value = eventArgument
                theform.submit()
          }
    // -->
    </script>
    </form>                  
    </body>                        
    </html>
      

  2.   

    直接点Post方式按钮即可
    aspxstring a = Request.Form["username"].Value;
      

  3.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=E6E35E3C-2C28-4DAD-ACBB-DB78D2785776
      

  4.   

    大家没明白我的意思,我是要用Java代码实现提交Post请求,不能通过HTML页面。
    现在已经知道java中的HttpURLConnection类可以实现发送Post请求,可带参数一直没有成功。不过如果用写流的方法则可以实现。(问题可能放错地方了,应该放到Java版中去)