当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET WebRequest.Create方法代码示例

本文整理汇总了VB.NET中System.Net.WebRequest.Create方法的典型用法代码示例。如果您正苦于以下问题:VB.NET WebRequest.Create方法的具体用法?VB.NET WebRequest.Create怎么用?VB.NET WebRequest.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.WebRequest的用法示例。


在下文中一共展示了WebRequest.Create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: Uri

Dim ourUri As New Uri(url)
' Create a 'WebRequest' object with the specified url. 

Dim myWebRequest As WebRequest = WebRequest.Create(url)

' Send the 'WebRequest' and wait for response.
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()

' "ResponseUri" property is used to get the actual Uri from where the response was attained.
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 

' Release resources of response object.
myWebResponse.Close()
开发者ID:VB.NET开发者,项目名称:System.Net,代码行数:17,代码来源:WebRequest.Create

示例2: Uri

' Create a new 'Uri' object with the specified string.
Dim myUri As New Uri("http://www.contoso.com")
' Create a new request to the above mentioned URL.	
Dim myWebRequest As WebRequest = WebRequest.Create(myUri)
'  Assign the response object of 'WebRequest' to a 'WebResponse' variable.
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()
开发者ID:VB.NET开发者,项目名称:System.Net,代码行数:6,代码来源:WebRequest.Create

示例3: MainClass

' 导入命名空间
Imports System
Imports System.Windows.Forms
Imports System.IO
Imports System.Net

Public Class MainClass

    Public Shared Sub Main()
        Try
          Dim theURL As New Uri("http://www.amazon.com/exec/obidos/ASIN/1893115992")
          Dim theRequest As WebRequest
          theRequest = WebRequest.Create(theURL)
          Dim theResponse As WebResponse
          theResponse = theRequest.GetResponse
          Dim aReader As New StreamReader(theResponse.GetResponseStream())
          Dim theData As String
          theData = aReader.ReadToEnd
    
          Console.WriteLine("Getting Amazon rank for ISBN # 1893115992")
    
          Console.WriteLine(theData)
    
        Catch E As Exception
          Console.WriteLine(E.StackTrace)
        End Try

    End Sub
End Class
开发者ID:VB程序员,项目名称:System.Net,代码行数:29,代码来源:WebRequest.Create


注:本文中的System.Net.WebRequest.Create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。