Reputation: 220
I have successfully sent (username/password) and received (true/false) values from my android app to .php page. Now i am trying to replace php page with aspx page I am having problem while receiving data at Asp.net page (android app to asp.net page), so pls help me in this regard with asp.net page.
My android code is as follows:
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();
}
}
Upvotes: 4
Views: 711
Reputation: 220
// Successful asp.net code is as follows:
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();
}
}
Upvotes: 2