Skip to main content

Microsoft Silverlight

Answered Question HttpWebResponse.GetResponseStream() is null-http status code 500RSS Feed

(0)

XASD
XASD

Member

Member

91 points

55 Posts

HttpWebResponse.GetResponseStream() is null-http status code 500

When HttpWebResponse.StatusCode!=HttpStatusCode.OK then GetResponseStream() is null, but how I can get response in case of http status code is 500 or something like that? Server trying to say something to me,but I can't read.

Thanks.

Yi-Lun Luo - MSFT
Yi-Lun L...

All-Star

All-Star

25052 points

2,747 Posts

Answered Question

Re: HttpWebResponse.GetResponseStream() is null-http status code 500

Unfortunately due to browser stack limitation, currently there's no way to get the actual http status code... If you have the control over the server, you can customize the response, so if something wrong happens, it still returns 200, but with a message indicating something wrong happened...

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.

vb7484
vb7484

Member

Member

2 points

1 Posts

Re: HttpWebResponse.GetResponseStream() is null-http status code 500

You need to catch the WebException that is thrown by HttpWebRequest.GetResponse. This exception includes useful info about Status, and the actual WebResponse that you're after. Just read the MSDN page: http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities