The getresponse of HTTP in WP7 throws an exception.

Source: Internet
Author: User

The HTTP request service was used yesterday to create an HTTP connection using httpwebrequest.

The result is always abnormal when the server response status is obtained. The following code shows the exception:

            try            {                HttpWebRequest request = ar.AsyncState as HttpWebRequest;                HttpWebResponse response = request.EndGetResponse(ar) as HttpWebResponse;                using (var stream = response.GetResponseStream())                {                    StreamReader reader = new StreamReader(stream);                    string msg = reader.ReadToEnd();                }            }            catch (Exception e)            {                string a = e.ToString();            }

In execution

HttpWebResponse response = request.EndGetResponse(ar) as HttpWebResponse;

An exception is reported in this statement:
Remote Server returned an error: notfound.


I still cannot solve this problem by referring to some documents.

After adjusting the parameters in the POST request, the returned status code is 200.

The main reason is that the server has some specific requirements on the post parameter field, such as the length required or the field that cannot be omitted.


The strange thing is that if a parameter error occurs, the received status code should be 601 (the status code defined by the server, which is an invalid parameter), but it directly throws an exception; however, the enumerated quantity in httpstatuscode does not have this value (2XX to 5xx). I don't know if this problem causes an exception.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.