Export (0) Print
Expand All

CredentialCache.Add Method (String, Int32, String, NetworkCredential)

Note: This method is new in the .NET Framework version 2.0.

Adds a NetworkCredential instance to the credential cache and associates it with a host computer, port, and authentication protocol.

Namespace: System.Net
Assembly: System (in system.dll)

public void Add (
	string host,
	int port,
	string authenticationType,
	NetworkCredential credential
)
public void Add (
	String host, 
	int port, 
	String authenticationType, 
	NetworkCredential credential
)
public function Add (
	host : String, 
	port : int, 
	authenticationType : String, 
	credential : NetworkCredential
)

Parameters

host

A String that identifies the host computer.

port

A Int32 that specifies the port to connect to on host.

authenticationType

A String that identifies the authentication scheme used when connecting to host using cred. See Remarks.

credential

The NetworkCredential to add to the credential cache.

Exception typeCondition

ArgumentNullException

host is a null reference (Nothing in Visual Basic).

-or-

authType is a null reference (Nothing in Visual Basic).

ArgumentException

authType not an accepted value. See Remarks.

ArgumentOutOfRangeException

port is less than zero.

This method places a NetworkCredential instance into the CredentialCache. The cache stores credentials in the order in which they are added to it. When the GetCredential(String,Int32,String) method is called, it returns a NetworkCredential instance that is selected by matching the host, port, and authType. The comparison is done case-insensitively.

The supported values for authType are "NTLM", "Digest", "Kerberos", and "Negotiate". This method does not work for HTTP or FTP protocols.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft