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

hii,

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.";
return;
}

        Address address = await ReverseGeocodeCurrentLocation();
        DisplayAddress(address);

        #region Postdata
        try
        {
            string url = "http://192.168.1.88:8044/api/sampleLocation/";
            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...");
                    }
                    else
                    {
                        System.Console.Out.WriteLine("Response Body: \r\n {0}", locationText.Text);
                    }
                }
            }
        }
        catch (System.Exception ex)
        {
            Console.WriteLine("Generic Exception Handler: {0}", addressText.Text);
        }


    #endregion

how to solve these errors..???

Answers

  • 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.