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
Assembly:  System (in System.dll)

ICredentials Credentials { get; set; }

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 : IWebProxy

{

	// The credentials to be used with the web proxy.
	private ICredentials iCredentials;

	// Uri of the associated proxy server.
	private Uri webProxyUri;

	public WebProxy_Interface(Uri proxyUri) {

		webProxyUri = proxyUri;	

	}

	// Get and Set the Credentials property.
	public ICredentials Credentials {
		get {
			return iCredentials;
		}
		set {
			if(iCredentials != value)
				iCredentials = value;
		}
	}

	// Return the web proxy for the specified destination(destUri).
	public Uri GetProxy(Uri destUri) {

		// Always use the same proxy.
		return webProxyUri;

	}

	// Return whether the web proxy should be bypassed for the specified destination(hostUri).
	public bool IsBypassed(Uri hostUri) {

		// Never bypass the proxy.
		return false;

	}
};


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2016 Microsoft