Forum Xamarin Xamarin.Android

System.Net.WebException: The remote server returned an error


I tried to find the Current mobile location and Coordinates values, after that Post the Coordinates values into my localserver.
When I post the values in the server it will display this error.

"System.Net.WebException: The remote server returned an error: (400) Bad Request."
Timed out waiting for response from server

async void AddressButton_OnClick(object sender, EventArgs eventArgs)
if (currentLocation == null)
addressText.Text = "Can't determine the current address. Try again in a few minutes.";

        Address address = await ReverseGeocodeCurrentLocation();

        #region Postdata
            string url = "";
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";
            request.ContentLength = 0;
            request.Timeout = 2000;
            request.ContentType = "application/x-www-form-urlencoded";
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)  
                if (response.StatusCode != HttpStatusCode.OK)
                    System.Console.Out.WriteLine("Error fetching data. Server returned status code: {0}", response.StatusCode);
                using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                    var content = reader.ReadToEnd();
                    if (string.IsNullOrWhiteSpace(content))
                        System.Console.Out.WriteLine("Response contained empty body...");
                        System.Console.Out.WriteLine("Response Body: \r\n {0}", locationText.Text);
        catch (System.Exception ex)
            Console.WriteLine("Generic Exception Handler: {0}", addressText.Text);


how to solve these errors..???


  • NaniiNanii USMember

    when I post the data it will display these type of errors.
    System.ObjectDisposedException: Cannot access a disposed object.

    Object name: 'handle'.
    System.Net.Sockets.SocketException: interrupted

  • aminem1zakiaminem1zaki Member

    i have the same problem ....

Sign In or Register to comment.