How to convert MSXML2.XMLHTTP.3.0 calls to .Net in C#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Currently I do the below in ASP server side code.
var xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");
xmlHttpReq.open("GET", "HTTP://MYURL", false);
xmlHttpReq.send();
var returnValue = xmlHttpReq.responseText;

How can I duplicate this in .Net?

Thanks
 
mike

You can try httpWebRequest & httpWebResponse

HttpWebRequest req = (HttpWebRequest)HttpWebRequest .Create(http://myurl) ;
HttpWebResponse resp = (HttpWebResponse)req.GetResponse() ;

StreamReader sr = new StreamReader(resp.GetResponseStream,Encoding.ASCII);

Console.WriteLine(sr.ReadToEnd())
sr.Close();

also see
http://msdn.microsoft.com/library/d...ml/frlrfsystemnethttpwebrequestclasstopic.asp

I did not test the actual code, but this might be what you are looking for

Henk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

XMLHTTP 2
XMLHTTP-Pls help 1
XMLHTTP 4
XMLHTTP question 1
Control the response of xmlHTTP 3
XmlHttp (Ajax) Show Waiting Message 2
Managed Code alternative for MSXML2.XMLHTTP 0
Download files using MSXML2.XMLHTTP 0

Back
Top