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
 
Back
Top