剛剛看到一段簡短的程式是使用vb.net 開發應用程式來對網站使用POST的方式傳送資料
Dim web As New System.Net.WebClIEnt()
web.headers.Add("Content-Type","application/x-www-form-urlencoded")
Dim d As Byte() = System.Text.EnCoding.ASCII.GetBytes("SEA
Dim res As Byte() = web.UploadData("http://www.baIDu.com","POST",d)
msgBox(System.Text.EnCoding.ASCII.GetStr
比起下面這種方法是簡單許多!
Dim httpResp As System.Net.httpWebResponse Dim httpUrl2 As New System.Uri("http://www.baIDu.com") Dim req As httpWebRequest req = CType(WebRequest.Create(httpUrl2),httpWebRequest) req.Method = "POST" req.ContentType = "application/x-www-form-urlencoded" Dim bytesData() As Byte = EnCoding.ASCII.GetBytes("SEARCHSTRING=test") req.ContentLength = bytesData.Length Dim poststream As Stream = req.GetRequestStream() poststream.Write(bytesData,bytesData.Length) poststream.Close() Dim res As httpWebResponse = CType(req.GetResponse(),httpWebResponse) Dim reader As StreamReader = New StreamReader(res.GetResponseStream,System.Text.EnCoding.GetEnCoding("BIG5")) Dim respHTML As String = reader.ReadToEnd() res.Close() MsgBox(respHTML)
总结以上是内存溢出为你收集整理的vb.net http post的两种方法全部内容,希望文章能够帮你解决vb.net http post的两种方法所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)