Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6347299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:11:14+00:00 2026-05-24T21:11:14+00:00

I’m doing what is usually a simple http post on windows phone 7 (code

  • 0

I’m doing what is usually a simple http post on windows phone 7 (code below). When I look at fiddler during the post I see this result from the server

HTTP/1.1 500 Internal Server Error Cache-Control: private
Content-Type: application/json; charset=utf-8 Server:
Microsoft-IIS/7.5 jsonerror: true X-AspNet-Version: 2.0.50727
X-Server: www03 X-Site: prod Date: Tue, 16 Aug 2011 03:49:51 GMT
Content-Length: 220

{“Message”:”We’re sorry … }

When I put a try catch over the async post I can’t find anything other than

{System.Net.WebException: The remote server returned an error:
NotFound. —> System.Net.WebException: The remote server returned an
error: NotFoun…

My question is this: how can I get the actual message (shown in fiddler) from this exception? or how can I avoid this exception altogether and get the json back so I can parse it for the actual error message?

Thank you in advance

    public void Checkout(ResponseAndCookies responseAndCookies)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost/checkout");
        request.ContentType = "application/json";
        request.CookieContainer = responseAndCookies.CookieContainer;
        request.Method = "POST";
        request.AllowAutoRedirect = false;
        request.Accept = "application/json";

        request.BeginGetRequestStream(new AsyncCallback(GetRequest), request);
    }

    private void GetRequest(IAsyncResult asyncResult)
    {
        var json = "{\"valid\":true}";
        byte[] byteArray = Encoding.UTF8.GetBytes(json);

        HttpWebRequest request = (HttpWebRequest) asyncResult.AsyncState;
        Stream newStream = request.EndGetRequestStream(asyncResult);
        newStream.Write(byteArray, 0, byteArray.Length);
        newStream.Close();

        request.BeginGetResponse(new AsyncCallback(GetResponse), request);
    }

    private void GetResponse(IAsyncResult asyncResult)
    {
            var response = ReadResponse(asyncResult); //if I try catch this I get the exception listed above :(
    }

    private ResponseAndCookies ReadResponse(IAsyncResult result)
    {
        Stream dataStream = null;
        HttpWebRequest request = (HttpWebRequest) result.AsyncState;
        HttpWebResponse response = request.EndGetResponse(result) as HttpWebResponse;
        dataStream = response.GetResponseStream();
        StreamReader reader = new StreamReader(dataStream);
        string responseFromServer = reader.ReadToEnd();
        reader.Close();
        dataStream.Close();
        response.Close();   

        var responseAndCookies = new ResponseAndCookies
                                     {CookieContainer = request.CookieContainer, Markup = responseFromServer};

        return responseAndCookies;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:11:15+00:00Added an answer on May 24, 2026 at 9:11 pm

    HTTP 500 isn’t the same as “Not Found” (that would be HTTP 404). So your exception isn’t actually related. Anyway, you obviously need to read the content response stream.

    You can read the response using the WebException.Response property, inside your catch clause.

    When that’s said, I would recommend you to look into a framework like RestSharp. No point writing so much code yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.