Solved

HttpWebResponse Question

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASCX file or a newer alternative? 1 34
daypilot scheduler 3 26
EF5: Question about Metadata Artifact Processing 4 15
PrintingFoundIt(Almost!(Damn!)) 1 26
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…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

786 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