Viewing source for Recipe2101vb.aspx

<%@ Page %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net" %>
<script language="VB" runat="server">

Private Sub SubmitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
	Dim RequestUrl As String = UrlTextBox.Text

	Dim WebRequestObject As HttpWebRequest
	Dim sr As StreamReader
	Dim WebResponseObject As HttpWebResponse
	
	Try
		WebRequestObject = CType(WebRequest.Create(RequestUrl), HttpWebRequest)
		WebRequestObject.Method = "GET"

		WebResponseObject = CType(WebRequestObject.GetResponse(), HttpWebResponse)
		sr = New StreamReader(WebResponseObject.GetResponseStream)

		Dim Results as string = sr.ReadToEnd
		WebResponseLabel.Text = Results
		WebResponseText.Text = Results
	Finally
		Try
			sr.Close()
		Catch
		End Try
		
		Try
			WebResponseObject.Close()
			WebRequestObject.Abort()
		Catch
		End Try
	End Try
End Sub

</script>
<html>
	<head>
		<title></title>
	</head>
	<body>
		<form runat="server">
			<asp:TextBox Runat="server" id="UrlTextbox" Text="http://www.cnn.com" />
			<asp:Button Runat="server" ID="SubmitButton" Text="Get Page" OnClick="SubmitButton_Click" /><br>
			<asp:TextBox Runat="server" id="WebResponseText" Width="780" Height="300" TextMode="MultiLine" />
			<asp:Label Runat="server" ID="WebResponseLabel" />
		</form>
	</body>
</html>