Hi, Could someone please help me with this
I am trying to do use the following code to post a form and get
response but it 's keep giving me a error "The operation has
timed-out." on this line
oRespons = CType(oRequest. GetResponse(), HttpWebResponse )
I have to us Unicode Encoding so it knows national charactor.
Please help how can i make this work
here is the code
Public Function DoHttpRequest(B yVal strWWWAddress As String, ByVal
strdata As String, ByRef strResult As String, ByRef iStatusCode As
HttpStatusCode) As Boolean
Dim bolReturn As Boolean
Dim strMethodName As String
strResult = ""
iStatusCode = HttpStatusCode. Unused
Dim timeRequestStar t As DateTime = DateTime.Now
Dim oRequest As HttpWebRequest = Nothing
Dim oInStream As Stream = Nothing
Dim oRespons As HttpWebResponse = Nothing
Dim readStream As StreamReader = Nothing
Dim oEncoding As Encoding = Encoding.Unicod e
Try
Dim bSendData As Boolean
strMethodName = "POST"
oRequest = CType(WebReques t.Create(strWWW Address),
HttpWebRequest)
oRequest.Method = strMethodName
oRequest.Conten tType = "applicatio n/x-www-form-urlencoded"
oRequest.Servic ePoint.Expect10 0Continue = False
oRequest.Timeou t = 10 * 1000
' oRequest.Creden tials = New NetworkCredenti al("UserName",
"Password")
oRequest.Servic ePoint.Connecti onLimit = 15
If bSendData Then
oInStream = oRequest.GetReq uestStream()
Dim data As Byte() = oEncoding.GetBy tes(strdata)
oInStream.Write (data, 0, data.Length)
oInStream.Flush ()
oInStream.Close ()
oInStream = Nothing
End If
oRespons = CType(oRequest. GetResponse(), HttpWebResponse )
readStream = New StreamReader(oR espons.GetRespo nseStream(),
Encoding.Unicod e)
strResult = readStream.Read ToEnd()
readStream.Clos e()
readStream = Nothing
iStatusCode = oRespons.Status Code
oRespons.Close( )
oRespons = Nothing
bolReturn = True
Catch ex As Exception
' Me.EmailAdmin(e x.Message, ex.StackTrace)
'bolReturn = False
Finally
If Not (oInStream Is Nothing) Then
oInStream.Close ()
End If
If Not (readStream Is Nothing) Then
readStream.Clos e()
End If
If Not (oRespons Is Nothing) Then
oRespons.Close( )
End If
End Try
Return bolReturn
End Function 'DoHttpRequest
to call this function
in form_load
Dim param As Byte() =
HttpContext.Cur rent.Request.Bi naryRead(HttpCo ntext.Current.R equest.ContentL ength)
Dim ps As String = Encoding.Unicod e.GetString(par am)
ps += "&cmd=_noti fy-validate"
Dim status As System.Net.Http StatusCode
If DoHttpRequest(" https://www.paypal.com/cgi-bin/webscr",
ps, strResponse, status) = False Then
' do insert to DB
end if
-------------------------------------------------------------------------------------------------------
please reply to my email becasue i had a hard time finding what i
posted so i had to repost again, my email is me******@hotmai l.com
Thank you