XMLHTTP Object in C#

Need some sample code in C# to see how to setup the XMLHTTP object and send the data.

thanks!
tgramboAsked:
Who is Participating?
 
b1xml2Commented:
i wonder if this is Jat from DOJ?!

anyways, Jat, that example of using the XMLHTTP example is from Javascript, not C#.

Add a reference to the Msxml 3/4 in your project
=================================
using MSXML2;

... code
// to get page data (using msxml4)
XMLHTTP40 http = new XMLHTTP40();
http.open("GET","http://www.data/hello.html",false,null,null);
http.send();
string value = http.responseText;

// to post data
DOMDocument40 document = new DOMDocument40();
document.async = false;
document.loadXML("...");
XMLHTTP40 http = new XMLHTTP40();
http.open("POST","http://www.data/hello.html",false,null,null);
http.send(document);




0
 
jatinderalaghCommented:
How to use XMLHTTP  this you can find in MSDN
http://msdn.microsoft.com/msdnmag/issues/04/08/CuttingEdge/default.aspx

Jatinder
0
 
jatinderalaghCommented:
>>i wonder if this is Jat from DOJ?!

@ b1xml2 : What you mean ??

0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
b1xml2Commented:
mistaken identity, i thought you were someone I knew =)
0
 
leroopsinCommented:
This is the list of link which I can share them to you.

1. http://developer.apple.com/internet/webcontent/xmlhttpreq.html
2. http://www.devx.com/getHelpOn/10MinuteSolution/20358
3. http://www.codeproject.com/asp/goiscode.asp

Sin Le

Here is the code of project which uses ServerXMLHTTP

--- File XferXML.asp-----
<%
cmd = request("cmd")
sid = request("id")

if sid="null" then
      sid=""
end if

retval = SendCommand(cmd,sid)

if cmd="online" then
      sid = GetData(retval)
      session("surferId")=sid
end if

response.write(retval)
%>

<%
Function SendCommand(cmd,sid)
      set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP")
      ipserver = "http://203.162.100.186"
      url = ipserver & "/ChatCmdXML.aspx?cmd=" & cmd
      
      if cmd="getcmd" then
            if session("surferId")<>"" then
                  url = url & "&id=" & session("surferId")
            else
                  if sid<>"" then
                        url = url & "&id=" & sid
                  end if
            end if
      end if

      if cmd="online" then
            if sid<>"" and sid<>"undefined" then
                  url = url & "&id=" & sid
            end if
      end if
      
      xmlHttp.Open "GET", url, False
      xmlHttp.send

      SendCommand = xmlHttp.responseText
End Function

Function GetCmd(strxml)
      set xmlDoc = CreateObject("MSXML2.DOMDocument")
      xmlDoc.loadXML strxml
      set tree = xmlDoc.documentElement
      GetCmd = tree.childNodes(0).text
End Function

Function GetData(strxml)
      set xmlDoc = CreateObject("MSXML2.DOMDocument")
      xmlDoc.loadXML strxml
      set tree = xmlDoc.documentElement
      GetData = tree.childNodes(1).text
End Function

Function GetSurferId()
      GetSurferId = Request.Cookies("MyCookie")("surferId")
End Function

Function SetSurferId(id)
      Response.Cookies("MyCookie").Expires = Date + 365
      Response.Cookies("MyCookie").Domain = "eglobalcallsolutions.com"
      Response.Cookies("MyCookie")("surferId") = id
End Function

%>
0
 
b1xml2Commented:
leeropsin, if you were to read the question, it would be clear that the asker wants sample code in C#. Please try to be relevant.
0
 
b1xml2Commented:
Plus that's ASP/VBScript and this is .NET and C# and more to the point. It may well be they are using WinForms.

You just blotted this thread with long irrelevant code.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.