Solved

HttpWebResponse Question

Posted on 2009-04-14
2
255 Views
Last Modified: 2012-05-06
I submitted a question earlier, but was a little vague as to exactly what I was trying to do.

So I am using an HttpWebRequest object to submit a POST to a URL. The ContentType of that object is "application/x-www-form-urlencoded".

Now, when I get an HttpWebResponse object from that request object, what I'm getting is HTML text. But one of the parameters in my query string indicates that the response is going to be "text/xml"

I actually want to get at that XML text which I'm assuming is buried in the response object somewhere because when I manually submit the query string in a web browser, it gives me the XML response.

Is there any way to define what the ContentType of the WebResponse.GetResponseStream() will give me?
0
Comment
Question by:ViceroyFizzlebottom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
Gorkem Yuksel earned 500 total points
ID: 24142472
Hi,

The webresponse stream is just that.. it's a stream of data.. how you interpret is what matters.  

If you know for sure that what you are getting back is HTML, then it may be the POST that isn't posting the "form" properly, hence the result may be an HTML error response.

If it is indeed xml, just read the stream into a StringReader object and then use the LoadXml() method of an XmlDocument object to load it in as XML.

Cheers,

G.
0
 
LVL 6

Author Comment

by:ViceroyFizzlebottom
ID: 24143289
*blush*

Ya, didn't even think of that. After further investigation it was being encoded wrong, but when manually submitting it using Firefox, the browser must have been smart enough to encode it properly for me :(

In any event, thanks.

0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question