HttpClientHandler.UseDefaultCredentials 属性

定义

获取或设置一个值,该值控制处理程序是否随请求一起发送默认凭据。Gets or sets a value that controls whether default credentials are sent with requests by the handler.

public:
 property bool UseDefaultCredentials { bool get(); void set(bool value); };
public bool UseDefaultCredentials { get; set; }
member this.UseDefaultCredentials : bool with get, set
Public Property UseDefaultCredentials As Boolean

属性值

如果使用默认凭据,则为 true;否则为 falsetrue if the default credentials are used; otherwise false. 默认值为 falseThe default value is false.

注解

将此属性设置为 true 当服务器请求的 HttpClientHandler 对象发出的请求使用当前登录用户的凭据进行身份验证时。Set this property to true when requests made by the HttpClientHandler object should, if requested by the server, be authenticated using the credentials of the currently logged on user. 对于客户端应用程序,这在大多数情况下都是所需的行为。For client applications, this is the desired behavior in most scenarios. 对于中间层应用程序(如 ASP.NET 应用程序),通常会将 Credentials 属性设置为代表其发出请求的客户端的凭据。For middle-tier applications, such as ASP.NET applications, instead of using this property, you would typically set the Credentials property to the credentials of the client on whose behalf the request is made.

适用于