HTTP GET in VB.NET

后端 未结 7 644
离开以前
离开以前 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:16

    Public Function getLoginresponce(ByVal email As String, ByVal password As String) As String
        Dim requestUrl As String = "your api"
        Dim request As HttpWebRequest = TryCast(WebRequest.Create(requestUrl), HttpWebRequest)
        Dim response As HttpWebResponse = TryCast(request.GetResponse(), HttpWebResponse)
        Dim dataStream As Stream = response.GetResponseStream()
        Dim reader As New StreamReader(dataStream)
        Dim responseFromServer As String = reader.ReadToEnd()
        Dim result = responseFromServer
        reader.Close()
        response.Close()
        Return result
    End Function
    

提交回复
热议问题