我知道以前有人问过这个问题,我一直在寻找答案,但我是 Post 的新手,我不知道出了什么问题,在某些网站上它工作正常,但是当我用它访问大学的内部网时,我不断得到:
需要使用 HTTP cookie 来验证授权信息
请告诉我哪里做错了,这是我的代码:
Dim cookies = New CookieContainer()
ServicePointManager.Expect100Continue = False
Dim request As HttpWebRequest = DirectCast(WebRequest.Create("http://banapp01*******/PROD/twbkwbis.P_ValLogin"), HttpWebRequest)
request.CookieContainer = cookies
'Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
'Dim cookieCount As Integer = cookies.Count
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0"
request.Method = "POST"
request.Referer = "http://banapp01.*******/PROD/twbkwbis.P_WWWLogin"
request.ContentType = "application/x-www-form-urlencoded"
Using requestStream = request.GetRequestStream()
Using writer = New StreamWriter(requestStream)
writer.Write("sid=" & TextBox1.Text & "&PIN=" & TextBox2.Text)
End Using
End Using
Using responseStream = request.GetResponse().GetResponseStream()
Using reader = New StreamReader(responseStream)
Dim result = reader.ReadToEnd()
RichTextBox1.Text = result
End Using
End Using
谁能告诉我怎么了?或者我需要如何正确工作?我已经研究 Post and Get 5 天了,但仍然失败!我只是希望我的项目是完美的:S