System.Net.WebClient.Credentials Property

Gets or sets the network credentials that are sent to the host and used to authenticate the request.

Syntax

public ICredentials Credentials { get; set; }

Value

A System.Net.ICredentials containing the authentication credentials for the request. The default is null.

Remarks

The WebClient.Credentials property contains the authentication credentials used to access a resource on a host. In most client-side scenarios, you should use the CredentialCache.DefaultCredentials, which are the credentials of the currently logged on user. To do this, set the WebClient.UseDefaultCredentials property to true instead of setting this property.

If the System.Net.WebClient class is being used in a middle tier application, such as an ASP.NET application, the CredentialCache.DefaultCredentials belong to the account running the ASP page (the server-side credentials). Typically, you would set this property to the credentials of the client on whose behalf the request is made.

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0