VB.Net by API/System.Net/WebRequest — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 12:49, 26 мая 2010
Содержание
- 1 WebRequest.Address
- 2 WebRequest.AllowAutoRedirect
- 3 WebRequest.AllowWriteStreamBuffering
- 4 WebRequest.ClientCertificates
- 5 WebRequest.Connection
- 6 WebRequest.ConnectionGroupName
- 7 WebRequest.ContentLength
- 8 WebRequest.ContentType
- 9 WebRequest.Create
- 10 WebRequest.GetResponse
- 11 WebRequest.MediaType
- 12 WebRequest.Method
- 13 WebRequest.PreAuthenticate
- 14 WebRequest.ProtocolVersion
- 15 WebRequest.Referer
- 16 WebRequest.RequestUri
- 17 WebRequest.TransferEncoding
- 18 WebRequest.UserAgent
WebRequest.Address
Imports System.Net
Imports System.Net.Sockets
Public Class Tester
Public Shared Sub Main
Dim httpReq As System.Net.HttpWebRequest
Try
Dim httpURL As New System.Uri("http://www.vbex.ru/index.htm?key=value")
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
Console.WriteLine("Address: " & httpReq.Address.ToString)
Console.WriteLine("AllowAutoRedirect: " & httpReq.AllowAutoRedirect.ToString)
Console.WriteLine("AllowWriteStreamBuffering: " & httpReq.AllowWriteStreamBuffering.ToString)
Console.WriteLine("ClientCertificates: " & httpReq.ClientCertificates.ToString)
Catch ex As Exception
Console.WriteLine(ex.StackTrace.ToString())
End Try
End Sub
End Class
WebRequest.AllowAutoRedirect
Imports System.Net
Imports System.Net.Sockets
Public Class Tester
Public Shared Sub Main
Dim httpReq As System.Net.HttpWebRequest
Try
Dim httpURL As New System.Uri("http://www.vbex.ru/index.htm?key=value")
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
Console.WriteLine("Address: " & httpReq.Address.ToString)
Console.WriteLine("AllowAutoRedirect: " & httpReq.AllowAutoRedirect.ToString)
Console.WriteLine("AllowWriteStreamBuffering: " & httpReq.AllowWriteStreamBuffering.ToString)
Console.WriteLine("ClientCertificates: " & httpReq.ClientCertificates.ToString)
Catch ex As Exception
Console.WriteLine(ex.StackTrace.ToString())
End Try
End Sub
End Class
WebRequest.AllowWriteStreamBuffering
Imports System.Net
Imports System.Net.Sockets
Public Class Tester
Public Shared Sub Main
Dim httpReq As System.Net.HttpWebRequest
Try
Dim httpURL As New System.Uri("http://www.vbex.ru/index.htm?key=value")
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
Console.WriteLine("Address: " & httpReq.Address.ToString)
Console.WriteLine("AllowAutoRedirect: " & httpReq.AllowAutoRedirect.ToString)
Console.WriteLine("AllowWriteStreamBuffering: " & httpReq.AllowWriteStreamBuffering.ToString)
Console.WriteLine("ClientCertificates: " & httpReq.ClientCertificates.ToString)
Catch ex As Exception
Console.WriteLine(ex.StackTrace.ToString())
End Try
End Sub
End Class
WebRequest.ClientCertificates
Imports System.Net
Imports System.Net.Sockets
Public Class Tester
Public Shared Sub Main
Dim httpReq As System.Net.HttpWebRequest
Try
Dim httpURL As New System.Uri("http://www.vbex.ru/index.htm?key=value")
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
Console.WriteLine("Address: " & httpReq.Address.ToString)
Console.WriteLine("AllowAutoRedirect: " & httpReq.AllowAutoRedirect.ToString)
Console.WriteLine("AllowWriteStreamBuffering: " & httpReq.AllowWriteStreamBuffering.ToString)
Console.WriteLine("ClientCertificates: " & httpReq.ClientCertificates.ToString)
Catch ex As Exception
Console.WriteLine(ex.StackTrace.ToString())
End Try
End Sub
End Class
WebRequest.Connection
Imports System.Net
Imports System.Net.Sockets
Public Class Tester
Public Shared Sub Main
Dim httpReq As System.Net.HttpWebRequest
Try
Dim httpURL As New System.Uri("http://www.vbex.ru/index.htm?key=value")
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
If httpReq.Connection <> Nothing Then
Console.WriteLine("Connection: " & httpReq.Connection.ToString)
End If
If httpReq.ConnectionGroupName <> Nothing Then
Console.WriteLine("ConnectionGroupName: " & httpReq.ConnectionGroupName.ToString)
End If
If httpReq.ContentLength <> -1 Then
Console.WriteLine("ContentLength: " & httpReq.ContentLength.ToString)
End If
If httpReq.ContentType <> Nothing Then
Console.WriteLine("ContentType: " & httpReq.ContentType.ToString)
End If
Catch ex As Exception
Console.WriteLine(ex.StackTrace.ToString())
End Try
End Sub
End Class
WebRequest.ConnectionGroupName
Imports System.Net
Imports System.Net.Sockets
Public Class Tester
Public Shared Sub Main
Dim httpReq As System.Net.HttpWebRequest
Try
Dim httpURL As New System.Uri("http://www.vbex.ru/index.htm?key=value")
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
If httpReq.Connection <> Nothing Then
Console.WriteLine("Connection: " & httpReq.Connection.ToString)
End If
If httpReq.ConnectionGroupName <> Nothing Then
Console.WriteLine("ConnectionGroupName: " & httpReq.ConnectionGroupName.ToString)
End If
If httpReq.ContentLength <> -1 Then
Console.WriteLine("ContentLength: " & httpReq.ContentLength.ToString)
End If
If httpReq.ContentType <> Nothing Then
Console.WriteLine("ContentType: " & httpReq.ContentType.ToString)
End If
Catch ex As Exception
Console.WriteLine(ex.StackTrace.ToString())
End Try
End Sub
End Class
WebRequest.ContentLength
Imports System.Net
Imports System.Net.Sockets
Public Class Tester
Public Shared Sub Main
Dim httpReq As System.Net.HttpWebRequest
Try
Dim httpURL As New System.Uri("http://www.vbex.ru/index.htm?key=value")
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
If httpReq.Connection <> Nothing Then
Console.WriteLine("Connection: " & httpReq.Connection.ToString)
End If
If httpReq.ConnectionGroupName <> Nothing Then
Console.WriteLine("ConnectionGroupName: " & httpReq.ConnectionGroupName.ToString)
End If
If httpReq.ContentLength <> -1 Then
Console.WriteLine("ContentLength: " & httpReq.ContentLength.ToString)
End If
If httpReq.ContentType <> Nothing Then
Console.WriteLine("ContentType: " & httpReq.ContentType.ToString)
End If
Catch ex As Exception
Console.WriteLine(ex.StackTrace.ToString())
End Try
End Sub
End Class
WebRequest.ContentType
Imports System.Net
Imports System.Net.Sockets
Public Class Tester
Public Shared Sub Main
Dim httpReq As System.Net.HttpWebRequest
Try
Dim httpURL As New System.Uri("http://www.vbex.ru/index.htm?key=value")
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
If httpReq.Connection <> Nothing Then
Console.WriteLine("Connection: " & httpReq.Connection.ToString)
End If
If httpReq.ConnectionGroupName <> Nothing Then
Console.WriteLine("ConnectionGroupName: " & httpReq.ConnectionGroupName.ToString)
End If
If httpReq.ContentLength <> -1 Then
Console.WriteLine("ContentLength: " & httpReq.ContentLength.ToString)
End If
If httpReq.ContentType <> Nothing Then
Console.WriteLine("ContentType: " & httpReq.ContentType.ToString)
End If
Catch ex As Exception
Console.WriteLine(ex.StackTrace.ToString())
End Try
End Sub
End Class
WebRequest.Create
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.ru/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
WebRequest.GetResponse
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.ru/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
WebRequest.MediaType
Imports System.Net
Imports System.Net.Sockets
Public Class Tester
Public Shared Sub Main
Dim httpReq As System.Net.HttpWebRequest
Try
Dim httpURL As New System.Uri("http://www.vbex.ru/index.htm?key=value")
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
If httpReq.MediaType <> Nothing Then
Console.WriteLine("MediaType: " & httpReq.MediaType.ToString)
End If
Catch ex As Exception
Console.WriteLine(ex.StackTrace.ToString())
End Try
End Sub
End Class
WebRequest.Method
Imports System.Net
Imports System.Net.Sockets
Public Class Tester
Public Shared Sub Main
Dim httpReq As System.Net.HttpWebRequest
Try
Dim httpURL As New System.Uri("http://www.vbex.ru/index.htm?key=value")
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
Console.WriteLine("Method: " & httpReq.Method.ToString)
Console.WriteLine("PreAuthenticate: " & httpReq.PreAuthenticate)
Console.WriteLine("ProtocolVersion: " & httpReq.ProtocolVersion.ToString)
Catch ex As Exception
Console.WriteLine(ex.StackTrace.ToString())
End Try
End Sub
End Class
WebRequest.PreAuthenticate
Imports System.Net
Imports System.Net.Sockets
Public Class Tester
Public Shared Sub Main
Dim httpReq As System.Net.HttpWebRequest
Try
Dim httpURL As New System.Uri("http://www.vbex.ru/index.htm?key=value")
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
Console.WriteLine("Method: " & httpReq.Method.ToString)
Console.WriteLine("PreAuthenticate: " & httpReq.PreAuthenticate)
Console.WriteLine("ProtocolVersion: " & httpReq.ProtocolVersion.ToString)
Catch ex As Exception
Console.WriteLine(ex.StackTrace.ToString())
End Try
End Sub
End Class
WebRequest.ProtocolVersion
Imports System.Net
Imports System.Net.Sockets
Public Class Tester
Public Shared Sub Main
Dim httpReq As System.Net.HttpWebRequest
Try
Dim httpURL As New System.Uri("http://www.vbex.ru/index.htm?key=value")
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
Console.WriteLine("Method: " & httpReq.Method.ToString)
Console.WriteLine("PreAuthenticate: " & httpReq.PreAuthenticate)
Console.WriteLine("ProtocolVersion: " & httpReq.ProtocolVersion.ToString)
Catch ex As Exception
Console.WriteLine(ex.StackTrace.ToString())
End Try
End Sub
End Class
WebRequest.Referer
Imports System.Net
Imports System.Net.Sockets
Public Class Tester
Public Shared Sub Main
Dim httpReq As System.Net.HttpWebRequest
Try
Dim httpURL As New System.Uri("http://www.vbex.ru/index.htm?key=value")
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
If httpReq.Referer <> Nothing Then
Console.WriteLine("Referer: " & httpReq.Referer.ToString)
End If
Console.WriteLine("RequestUri: " & httpReq.RequestUri.ToString)
If (httpReq.RequestUri.ToString() <> httpReq.Address.ToString()) Then
Console.WriteLine("URL has been changed.")
End If
Catch ex As Exception
Console.WriteLine(ex.StackTrace.ToString())
End Try
End Sub
End Class
WebRequest.RequestUri
Imports System.Net
Imports System.Net.Sockets
Public Class Tester
Public Shared Sub Main
Dim httpReq As System.Net.HttpWebRequest
Try
Dim httpURL As New System.Uri("http://www.vbex.ru/index.htm?key=value")
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
If httpReq.Referer <> Nothing Then
Console.WriteLine("Referer: " & httpReq.Referer.ToString)
End If
Console.WriteLine("RequestUri: " & httpReq.RequestUri.ToString)
If (httpReq.RequestUri.ToString() <> httpReq.Address.ToString()) Then
Console.WriteLine("URL has been changed.")
End If
Catch ex As Exception
Console.WriteLine(ex.StackTrace.ToString())
End Try
End Sub
End Class
WebRequest.TransferEncoding
Imports System.Net
Imports System.Net.Sockets
Public Class Tester
Public Shared Sub Main
Dim httpReq As System.Net.HttpWebRequest
Try
Dim httpURL As New System.Uri("http://www.vbex.ru/index.htm?key=value")
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
If httpReq.TransferEncoding <> Nothing Then
Console.WriteLine("TransferEncoding: " & httpReq.TransferEncoding.ToString)
End If
If httpReq.UserAgent <> Nothing Then
Console.WriteLine("UserAgent: " & httpReq.UserAgent.ToString)
End If
Catch ex As Exception
Console.WriteLine(ex.StackTrace.ToString())
End Try
End Sub
End Class
WebRequest.UserAgent
Imports System.Net
Imports System.Net.Sockets
Public Class Tester
Public Shared Sub Main
Dim httpReq As System.Net.HttpWebRequest
Try
Dim httpURL As New System.Uri("http://www.vbex.ru/index.htm?key=value")
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
If httpReq.TransferEncoding <> Nothing Then
Console.WriteLine("TransferEncoding: " & httpReq.TransferEncoding.ToString)
End If
If httpReq.UserAgent <> Nothing Then
Console.WriteLine("UserAgent: " & httpReq.UserAgent.ToString)
End If
Catch ex As Exception
Console.WriteLine(ex.StackTrace.ToString())
End Try
End Sub
End Class