VB.Net by API/System.Net/HttpWebRequest

Материал из VB Эксперт
Версия от 15:49, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

HttpWebRequest.Create

<source lang="vbnet">

Imports System Imports System.Net Imports System.IO Imports System.Environment Module GetURL

   Sub Main()
       Dim sOutput As String
       Dim sURL As String = "http://www.vbex.ru"
       Try
          Dim objNewRequest As WebRequest = HttpWebRequest.Create(sURL)
          Dim objResponse As WebResponse = objNewRequest.GetResponse
          Dim objStream As New StreamReader(objResponse.GetResponseStream())
          sOutput = objStream.ReadToEnd()
       Catch eUFE As UriFormatException
           sOutput = "Error in URL Format: [" & sURL & "]" & NewLine() & eUFE.Message
       Catch eWEB As WebException
           sOutput = "Error With Web Request: " & NewLine() & eWEB.Message
       Catch e As Exception
           sOutput = e.ToString
       Finally
           Console.Write(sOutput)
       End Try
   End Sub

End Module


 </source>