All pastes #2024652 Raw Edit

Unnamed

public text v1 · immutable
#2024652 ·published 2010-12-20 18:04 UTC
rendered paste body
Private Function SendData(ByVal PostData As String, ByVal Site As String) As String
        Dim Request As HttpWebRequest = DirectCast(WebRequest.Create(Site), HttpWebRequest)
        Request.Method = "POST"
        Request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"
        Request.ContentType = "application/x-www-form-urlencoded"
        Request.AllowAutoRedirect = True
        Request.ServicePoint.Expect100Continue = False
        Request.ContentLength = PostData.Length
        Using ReqStream As Stream = Request.GetRequestStream()
            Dim Encoding As New UTF8Encoding()
            Dim PostBytes As Byte() = Encoding.GetBytes(PostData)
            ReqStream.Write(PostBytes, 0, PostBytes.Length)
        End Using
        Dim Result As String = String.Empty
        Using Response As HttpWebResponse = Request.GetResponse()
            Using RespStream As Stream = Response.GetResponseStream()
                Using Reader As New StreamReader(RespStream)
                    Result = Reader.ReadToEnd()
                End Using
            End Using
        End Using
        Return Result
    End Function