Unable to post data from a http web request

Hello everyone i have made my own web ap in ASP.Net and now i want to consume it in my android application but whenever i send the data using post request then my webservice dont recieve the sent data here is my code

EditText username = FindViewById<EditText>(Resource.Id.username);
        EditText password = FindViewById<EditText>(Resource.Id.password);
        Admin a = new Admin { Admin_username = username.Text, Admin_password = password.Text };

        string postDataString = Newtonsoft.Json.JsonConvert.SerializeObject(new { a });
        byte[] postDataByteArray = Encoding.UTF8.GetBytes(postDataString);
        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(url));
        request.ContentType = "application/json";
        request.Method = "POST";
        request.ContentLength = postDataByteArray.Length;
        request.KeepAlive = true;
        Stream dataStream = await request.GetRequestStreamAsync();
        dataStream.Write(postDataByteArray, 0, postDataByteArray.Length);
        dataStream.Close();
Tagged:

Best Answer

Answers

Sign In or Register to comment.