从Android应用程序发送的asp.net webform中接收用户名密码

我已成功发送(用户名/密码)并从我的
Android应用程序收到(真/假)值到.php页面.

现在我想用aspx页面替换php页面

我在Asp.net页面(android app到asp.net页面)接收数据时遇到问题,所以请用asp.net页面帮助我.

我的android代码如下:

    public void postLoginData() {
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://xyz/Default.aspx"); 
    try {
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("formData1", x));
        nameValuePairs.add(new BasicNameValuePair("formData2", y));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        HttpResponse response = httpclient.execute(httppost);
        result = inputStreamToString(response.getEntity().getContent()).toString();

    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
   }    

最佳答案 //成功的asp.net代码如下:

 public partial class _Default : System.Web.UI.Page 
 {
  string result,x,y;
   protected void Page_Load(object sender, EventArgs e)
   {
             x = Page.Request.Form["formData1"];
             y = Page.Request.Form["formData2"];

        if (x == y)
        {
            result = "true";
        }
        else
        {
            result = "false";
        }

        Response.Write(Server.HtmlEncode(result));
        Response.End();
    }
 }
点赞