Website login through code

website logins are an easy thing to do. All you have to remember is post all inputs for the form. Also always check for any javascript in the form that might need to be implemented in your code. Once you do that you are good to go. Here is a snippet of the post function.

 Private Function WebPost(ByVal URL As String, ByVal PostData As String) As String

            Dim responsedata As String
            Dim responsereader As IO.StreamReader
            webrequest = CType(webrequest.Create(URL), Net.HttpWebRequest)
            webrequest.Method = "POST"
            webrequest.UserAgent = "Mozilla/5.001 (windows; U; NT4.0; en-us) Gecko/25250101"

            webrequest.ContentType = "application/x-www-form-urlencoded"
            webrequest.CookieContainer = cookies
            ' write the form values into the request message
            Dim requestWriter As IO.StreamWriter = New IO.StreamWriter(webrequest.GetRequestStream())

            responsereader = New IO.StreamReader(webrequest.GetResponse().GetResponseStream())
            'and read the response
            responsedata = responsereader.ReadToEnd()

            Return responsedata
        Catch ex As Exception
        End Try

        Return ""

    End Function
This entry was posted in Uncategorized. Bookmark the permalink.

239 Responses to Website login through code

Leave a Reply

Your email address will not be published.