IM目前正試圖登錄到我的網站,這個工程然而,當它在記錄它不會重定向。這裏是我的代碼vb.net後登錄數據HttpWebRequest和餅乾
Dim request As WebRequest = WebRequest.Create("http://www.jamiehayles.com/test/login.php")
request.Method = "POST"
Dim postData As String = "username=testing&password=lmao1234"
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = byteArray.Length
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
Dim response As WebResponse = request.GetResponse()
Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
dataStream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
RichTextBox1.Text = responseFromServer
reader.Close()
dataStream.Close()
response.Close()
我的問題是,我需要Cookie重定向?如果有的話,任何幫助傢伙?
定義「它不會重定向」。什麼不會?你在哪裏執行或處理重定向? – David
對不起,如果我通過瀏覽器登錄它將重定向到「/account.php」,但是當我通過應用程序登錄它登錄,但它保持在login.php並不會重定向到accounts.php – user1757913
請檢查http:///stackoverflow.com/questions/8260736/webrequest-follow-redirect –