Solved

HttpWebResponse Question

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

749 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