WebRequest.Create creates a new WebRequest instance for the specified URI scheme.
Imports System.IO
Imports System.Net
Imports System.Text
Public Class MainClass
Shared Sub Main()
Dim url As String = "http://google.com"
Dim ourUri As New Uri(url)
Dim myWebRequest As WebRequest = WebRequest.Create(url)
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()
If ourUri.Equals(myWebResponse.ResponseUri) Then
Console.WriteLine(ControlChars.Cr + "Request Url : {0} was not redirected", url)
Else
Console.WriteLine(ControlChars.Cr + "Request Url : {0} was redirected to {1}", url, myWebResponse.ResponseUri)
End If
myWebResponse.Close()
End Sub
End Class
Related examples in the same category