HttpWebRequest.Credentials Property gets or sets authentication information for the request. : HttpWebRequest « Network Remote « VB.Net






HttpWebRequest.Credentials Property gets or sets authentication information for the request.

 

Imports System
Imports System.Net
Imports System.Text
Imports System.IO

    Public Class Test
        Public Shared Sub Main(ByVal args() As String)
        Dim request As HttpWebRequest = CType(WebRequest.Create(args(0)), HttpWebRequest)

        request.MaximumAutomaticRedirections = 4
        request.MaximumResponseHeadersLength = 4

        request.Credentials = CredentialCache.DefaultCredentials

        Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)

        Console.WriteLine("Content length is {0}", response.ContentLength)
        Console.WriteLine("Content type is {0}", response.ContentType)

        Dim receiveStream As Stream = response.GetResponseStream()

        Dim readStream As New StreamReader(receiveStream, Encoding.UTF8)
        Console.WriteLine(readStream.ReadToEnd())
        response.Close()
        readStream.Close()
    End Sub 'Main
End Class 'Test

   
  








Related examples in the same category

1.HttpWebRequest.Connection gets or sets the value of the Connection HTTP header.
2.HttpWebRequest.CookieContainer Property gets or sets the cookies associated with the request.