Dim postData As String = "username=myusername&password=mypassword&back=https%3A%2F%2Fecrew.mysite.com%2Fwtouch%2Fwtouch.exe%2Findex%3FMAC%3D0%26VER%3D0"
Dim tempCookies As New CookieContainer
Dim encoding As New UTF8Encoding
Dim byteData As Byte() = encoding.GetBytes(postData)
Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("https://portal.mysite.com/weblogin/bin/weblogin.cgi"), HttpWebRequest)
postReq.Method = "POST"
postReq.KeepAlive = True
postReq.CookieContainer = tempCookies
postReq.ContentType = "application/x-www-form-urlencoded"
postReq.Referer = "https://portal.mysite.com/weblogin/bin/weblogin.cgi"
postReq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.11) Gecko/20101012 Firefox/3.6.11 GTB7.1 ( .NET CLR 3.5.30729)"
postReq.ContentLength = byteData.Length
Dim postreqstream As Stream
Try
postreqstream = postReq.GetRequestStream()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error Logging on to the mysite Portal")
Error_Writer("mysite Portal Initial Login" & vbCrLf _
& ex.Message & vbCrLf)
Return
End Try
postreqstream.Write(byteData, 0, byteData.Length)
postreqstream.Close()
Dim postresponse As HttpWebResponse
postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)