Solved

HttpWebResponse Question

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 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

12 Experts available now in Live!

Get 1:1 Help Now