Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim sResponse As String = ""
- Dim webReq As HttpWebRequest = Nothing
- Dim webResp As HttpWebResponse = Nothing
- Dim reqStream As Stream = Nothing
- ' GetPostUrl return the URL only without any parameter.
- webReq = DirectCast(WebRequest.Create(ub.GetPostUrl()), HttpWebRequest)
- ' GetQueryString return the data for the post (param1=value1¶m2=value2...)
- Dim bytes As Byte() = Encoding.UTF8.GetBytes(ub.GetQueryString())
- webReq.Method = "POST"
- webReq.ContentType = "application/x-www-form-urlencoded"
- webReq.ContentLength = bytes.Length
- reqStream = webReq.GetRequestStream()
- reqStream.Write(bytes, 0, bytes.Length)
- reqStream.Close()
- Try
- webResp = DirectCast(webReq.GetResponse(), HttpWebResponse)
- If webResp.StatusCode = HttpStatusCode.OK Then
- Dim loResponseStream = New StreamReader(webResp.GetResponseStream(), Encoding.UTF8)
- sResponse = loResponseStream.ReadToEnd()
- End If
- webResp.Close()
- Catch ex As Exception
- WriteErrorInFile(ex)
- End Try
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement