HTTP GET in VB.NET

后端 未结 7 631
离开以前
离开以前 2020-11-27 15:25

What is the best way to issue a http get in VB.net? I want to get the result of a request like http://api.hostip.info/?ip=68.180.206.184

7条回答
  •  迷失自我
    2020-11-27 16:11

    Use the WebRequest class

    This is to get an image:

    Try
        Dim _WebRequest As System.Net.WebRequest = Nothing
        _WebRequest = System.Net.WebRequest.Create(http://api.hostip.info/?ip=68.180.206.184)
    Catch ex As Exception
        Windows.Forms.MessageBox.Show(ex.Message)
        Exit Sub
    End Try
    
    Try
        _NormalImage = Image.FromStream(_WebRequest.GetResponse().GetResponseStream())
    Catch ex As Exception
        Windows.Forms.MessageBox.Show(ex.Message)
        Exit Sub
    End Try
    

提交回复
热议问题