coldfusion cfhttp command interaction

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

Guest

Hello,
I'm Francesco and I write from Italy. I have a web site made in ColdFusion
that makes an HTTP request to another site in coldfusion using the tag
CFHTTP. The result of the call is sent to the page. Now I have to re-create
the web site in ASP.NET but I don't now how to generate and process an HTTP
request in .NET . I tryed the HttpWebRequest but maybe i'm in the wrong way.
Thanks in advance for the help
 
Hi Francesco,

If you know the names of the fields that the target page expects, you can
put them into a name/value collection and post them using
System.Net.WebClient.

Here's a little code that might get you started:


Sub DoPost()
Dim uriString As String = _
"http://localhost/p4320work/mySpecialPage.aspx"
Dim strGoName As String
strGoName = TextBox1.Text
' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient
Dim myNameValueCollection As New _
System.Collections.Specialized.NameValueCollection
myNameValueCollection.Add("go1", strGoName)
myNameValueCollection.Add("Button1", "")
Dim responseArray As Byte() = myWebClient.UploadValues _
(uriString, "POST", myNameValueCollection)

Label1.Text = "Response received was :" & _
System.Text.Encoding.ASCII.GetString(responseArray)
End Sub

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
Toronto
 
Ciao Ken,

I solved my problem thanks to your help.

Many thanks

Francesco

Ken Cox said:
Hi Francesco,

If you know the names of the fields that the target page expects, you can
put them into a name/value collection and post them using
System.Net.WebClient.

Here's a little code that might get you started:


Sub DoPost()
Dim uriString As String = _
"http://localhost/p4320work/mySpecialPage.aspx"
Dim strGoName As String
strGoName = TextBox1.Text
' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient
Dim myNameValueCollection As New _
System.Collections.Specialized.NameValueCollection
myNameValueCollection.Add("go1", strGoName)
myNameValueCollection.Add("Button1", "")
Dim responseArray As Byte() = myWebClient.UploadValues _
(uriString, "POST", myNameValueCollection)

Label1.Text = "Response received was :" & _
System.Text.Encoding.ASCII.GetString(responseArray)
End Sub

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
Toronto


Francesco said:
Hello,
I'm Francesco and I write from Italy. I have a web site made in ColdFusion
that makes an HTTP request to another site in coldfusion using the tag
CFHTTP. The result of the call is sent to the page. Now I have to
re-create
the web site in ASP.NET but I don't now how to generate and process an
HTTP
request in .NET . I tryed the HttpWebRequest but maybe i'm in the wrong
way.
Thanks in advance for the help
 

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

Back
Top