vbnet 用webrequest post/get 发送获取消息的例子

vbnet用webrequestpost/get发送获取消息的例子... vbnet 用webrequest post/get 发送获取消息的例子 展开
 我来答
FMUD1
2015-07-05 · TA获得超过1008个赞
知道大有可为答主
回答量:1289
采纳率:71%
帮助的人:905万
展开全部

httpwebrequest和webrequest差不多。

   Public Sub MakeSearch()
            Try
                Dim Http As Net.HttpWebRequest
                Http = DirectCast(System.Net.HttpWebRequest.Create(“网络地址?get参数”), Net.HttpWebRequest)
                Http.Method = "GET"
                Http.KeepAlive = True
                Using Rev As New IO.StreamReader(Http.GetResponse.GetResponseStream, System.Text.Encoding.Default)
                    MakeSearchHtml = Rev.ReadToEnd
                End Using
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

        Public Sub ShowResult()
            Try
                Dim Http As Net.HttpWebRequest
                Http = DirectCast(System.Net.HttpWebRequest.Create(“post服务器地址”), Net.HttpWebRequest)
                Http.Method = "POST"
                Http.ContentType = "application/x-www-form-urlencoded"
                Http.KeepAlive = True
                Using Send As New IO.StreamWriter(Http.GetRequestStream, System.Text.Encoding.Default)
                    Send.Write(CommandLine)'跟服务器通讯的命令。
                    Send.Flush()
                End Using
                Using Rev As New IO.StreamReader(Http.GetResponse.GetResponseStream, System.Text.Encoding.Default)
                    ShowResultHtml = Rev.ReadToEnd‘返回结果。
                End Using
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式