Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 10971
  • Last Modified:

XMLHTTP Object in C#

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

thanks!
0
tgrambo
Asked:
tgrambo
  • 4
  • 2
1 Solution
 
jatinderalaghCommented:
How to use XMLHTTP  this you can find in MSDN
http://msdn.microsoft.com/msdnmag/issues/04/08/CuttingEdge/default.aspx

Jatinder
0
 
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:
>>i wonder if this is Jat from DOJ?!

@ b1xml2 : What you mean ??

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now