WebRequest Class makes a request to a Uniform Resource Identifier (URI).
Imports System
Imports System.IO
Imports System.Net
Imports System.Text
Namespace Examples.System.Net
Public Class WebRequestGetExample
Public Shared Sub Main()
Dim request As WebRequest = WebRequest.Create("http://www.yourDomain.com/default.html")
request.Credentials = CredentialCache.DefaultCredentials
Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
Console.WriteLine(response.StatusDescription)
Dim dataStream As Stream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
Console.WriteLine(responseFromServer)
reader.Close()
dataStream.Close()
response.Close()
End Sub
End Class
End Namespace
Related examples in the same category