Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Credentials Property
Collapse the table of content
Expand the table of content

IWebProxy.Credentials Property

The credentials to submit to the proxy server for authentication.

Namespace:  System.Net
Assemblies:   System (in System.dll)
  System.Net.Primitives (in System.Net.Primitives.dll)

Property Credentials As ICredentials

Property Value

Type: System.Net.ICredentials
An ICredentials instance that contains the credentials that are needed to authenticate a request to the proxy server.

The Credentials property is an ICredentials instance that contains the authorization credentials to send to the proxy server in response to an HTTP 407 (proxy authorization) status code.

The following example uses the Credentials property to set the credentials that will be submitted to the proxy server for authentication.

Public Class WebProxy_Interface
    Implements IWebProxy

    'The credentials to be used with the web proxy. 
    Private iCredentials As ICredentials

    'Uri of the associated proxy server. 
    Private webProxyUri As Uri

    Sub New(proxyUri As Uri)

        webProxyUri = proxyUri
    End Sub 'New  

    'Get and Set the Credentials property. 

    Public Property Credentials() As ICredentials Implements IWebProxy.Credentials
            Return iCredentials
        End Get 
            If iCredentials Is value Then
                iCredentials = value
            End If 
        End Set 
    End Property 

    'Returns the web proxy for the specified destination(destUri). 
    Public Function GetProxy(destUri As Uri) As Uri Implements IWebProxy.GetProxy

        'Always use the same proxy. 
        Return webProxyUri
    End Function 'GetProxy

    'Returns whether the web proxy should be bypassed for the specified destination(hostUri). 
    Public Function IsBypassed(hostUri As Uri) As Boolean Implements IWebProxy.IsBypassed
       'Never bypass the proxy. 
        Return False 
    End Function 'IsBypassed 
End Class 'WebProxy_Interface

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft