' The following example uses the System, System.Net,
' and System.IO namespaces.
Public Shared Sub RequestMutualAuth(ByVal resource As Uri)
' Create a new HttpWebRequest object for the specified resource.
Dim request As WebRequest = CType(WebRequest.Create(resource), WebRequest)
' Request mutual authentication.
request.AuthenticationLevel = AuthenticationLevel.MutualAuthRequested
' Supply client credentials.
request.Credentials = CredentialCache.DefaultCredentials
Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
' Determine whether mutual authentication was used.
Console.WriteLine("Is mutually authenticated? {0}", response.IsMutuallyAuthenticated)
' Read and display the response.
Dim streamResponse As Stream = response.GetResponseStream()
Dim streamRead As New StreamReader(streamResponse)
Dim responseString As String = streamRead.ReadToEnd()
Console.WriteLine(responseString)
' Close the stream objects.
streamResponse.Close()
streamRead.Close()
' Release the HttpWebResponse.
response.Close()
End Sub