1
我試圖在VB.Net中使用POST請求登錄到cPanel。登錄時和發佈時我有正確的憑據,當它應該是'301'(使用Tamper Data Firefox Add-On進行分析)時,仍然會收到'未經授權(401)'響應。以下是我的發帖要求信息和功能。VB.Net 401未經授權的HTTP Web請求
Private Function POSTreq(ByVal URL$, ByVal Data$)
Dim tempCookie As New CookieContainer
Dim DataBytes As Byte() = Encoding.ASCII.GetBytes(Data)
Dim Request As HttpWebRequest = TryCast(WebRequest.Create(URL), HttpWebRequest)
Request.Method = "POST"
Request.ContentType = "application/x-www-form-urlencoded"
Request.ContentLength = DataBytes.Length
Dim PostData As Stream = Request.GetRequestStream()
PostData.Write(DataBytes, 0, DataBytes.Length)
PostData.Close()
Dim Response As HttpWebResponse = Request.GetResponse()
Dim ResponseStream As Stream = Response.GetResponseStream()
Dim StreamReader As New StreamReader(ResponseStream)
Dim Text$ = StreamReader.ReadToEnd()
Return Text
End Function
發佈網址
http://example.com:2082/login/
後數據
login_theme=cpanel&user=USERNAME&pass=PASSWORD&goto_uri=%2F