0
Reply

POSTing to another server

Vani

Vani

Mar 8 2006 3:59 PM
1.7k
Having some issues with HttpWebRequest and HttpWebResponse.
 
1. We migrated from ASP to ASP.Net
2. We have a third party company, a credit processing company which integrates with our web site. Working fine with ASP, since CC company requires "name-value" pairs in form which is POST method only.
3. Trying the same with ASP.Net but with no luck.
 
CODE
==
dim strVariables as string
strVariables = "myvariables to be passed to cc company like - amount=300&description=testing"
 
Dim httpwreq As HttpWebRequest = CType(WebRequest.Create(https://www.cccompany.com/), HttpWebRequest)
httpwreq.Method = "POST"
httpwreq.ContentType = "application/x-www-form-urlencode"
httpwreq.ContentLength = strVariables.Length
 
Dim myWriter As StreamWriter
Try
myWriter = New StreamWriter(httpwreq.GetRequestStream)
myWriter.Write(strVariables)
Catch ex As Exception
Response.Write(ex.ToString)
Response.Write(ex.Source)
End Try
 
Dim httpwresp As HttpWebResponse = CType(httpwreq.GetResponse, HttpWebResponse)
Dim sr As StreamReader
Dim result As String = ""
 
sr = New StreamReader(httpwresp.GetResponseStream())
result = sr.ReadToEnd()
sr.Close()
httpwresp.Close()

Response.Redirect(https://www.cccompany.com/)

==

Is something amiss above?