2015-09-26 99 views
-1

我一直在爲此工作了大約一天,我無法讓JMC通過httpwebrequests登錄我。 而且我用這個代碼,但它不工作,它只是讓我回到主頁:通過httpwebrequest登錄JMC vb.net

Dim postData As String = "ddl_schoolyear=2015&ddl_buildings=E&txt_username=txt_passworLogin_Button1.x=0&Login_Button1.y=0" 
    Dim tempCookies As New CookieContainer 
    Dim encoding As New UTF8Encoding 
    Dim byteData As Byte() = encoding.GetBytes(postData) 

    Dim postr As HttpWebRequest = DirectCast(WebRequest.Create("http.aspx"), HttpWebRequest) 
    postr.Method = "POST" 
    postr.KeepAlive = True 
    postr.CookieContainer = logcook 

    postr.ContentType = "application/x-www-form-urlencoded" 
    postr.Referer = "https://eastunioncsd.onlinejmc.com/Teacher/Login.aspx" 
    postr.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36" 
    postr.ContentLength = byteData.Length 

    Dim postrs As Stream = postr.GetRequestStream 
    postrs.Write(byteData, 0, byteData.Length) 
    postrs.Close() 

    Dim postre As HttpWebResponse 
    postre = DirectCast(postr.GetResponse(), HttpWebResponse) 
    tempCookies.Add(postre.Cookies) 
    logcook = logcook 

    Dim postreader As New StreamReader(postre.GetResponseStream()) 
    Dim thepage As String = postreader.ReadToEnd 
    RichTextBox1.Text = thepage 

請問有什麼解決什麼我做錯了嗎?我如何使用用戶名和密碼填充表單數據,在哪裏用webrequest登錄。如果所有的信息都是正確的,我假設被重定向到「https:/Teacher/Default.aspx」。我認爲它會把我帶到儀表板,但它只是進入登錄頁面。 任何幫助表示讚賞。

+0

你在哪裏希望重定向?你正在做的是使用Web服務POST響應填充RTB ...編輯你的問題並提供更多信息。另見[問]。祝你好運! –

+0

這是你需要詳細說明的問題,Web請求不會重定向你..從web請求中添加的cookies可能需要在登錄login.aspx後進入Default.aspx,但是你的代碼不會' t顯示'重定向'到default.aspx/dashboard.aspx –

+0

好吧,它的工作原理,它只是不顯示我重定向,有沒有辦法檢查重定向? –

回答

0

這是我從您在您的評論發佈的鏈接有:

enter image description here

+0

這是不可能的,它的教育網站在我的州運行,所以廣告是不允許的。無論如何,你從哪裏獲得mobliegiftcenter.com,它從來沒有在我以前的任何職位。 –