Solved

HttpWebResponse Question

Posted on 2009-04-14
2
250 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
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now