AuthenticationManager.PreAuthenticate(WebRequest, ICredentials) 方法

定义

注意

The AuthenticationManager Authenticate and PreAuthenticate methods are not supported and throw PlatformNotSupportedException.

预身份验证请求。

public:
 static System::Net::Authorization ^ PreAuthenticate(System::Net::WebRequest ^ request, System::Net::ICredentials ^ credentials);
[System.Obsolete("The AuthenticationManager Authenticate and PreAuthenticate methods are not supported and throw PlatformNotSupportedException.", DiagnosticId="SYSLIB0009", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static System.Net.Authorization? PreAuthenticate (System.Net.WebRequest request, System.Net.ICredentials credentials);
public static System.Net.Authorization? PreAuthenticate (System.Net.WebRequest request, System.Net.ICredentials credentials);
public static System.Net.Authorization PreAuthenticate (System.Net.WebRequest request, System.Net.ICredentials credentials);
[<System.Obsolete("The AuthenticationManager Authenticate and PreAuthenticate methods are not supported and throw PlatformNotSupportedException.", DiagnosticId="SYSLIB0009", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
static member PreAuthenticate : System.Net.WebRequest * System.Net.ICredentials -> System.Net.Authorization
static member PreAuthenticate : System.Net.WebRequest * System.Net.ICredentials -> System.Net.Authorization
Public Shared Function PreAuthenticate (request As WebRequest, credentials As ICredentials) As Authorization

参数

request
WebRequest

对 Internet 资源的请求。

credentials
ICredentials

与请求关联的凭据。

返回

如果可以对请求进行预身份验证,则为 Authorization 类的实例,否则为 null。 如果 credentialsnull,则此方法返回 null

属性

例外

仅限 .NET Core 和 .NET 5 及更高版本:在所有情况下。

requestnull

注解

如果身份验证模块可以对请求进行预身份验证,该方法 PreAuthenticate 将返回一个身份验证实例,并将授权信息提前发送到服务器,而不是等待资源发出质询。 RFC 2617 (HTTP 身份验证第 3.3 节概述了此行为:基本和摘要访问身份验证) 。 支持预身份验证的身份验证模块允许客户端通过避免身份验证质询导致的额外往返来提高服务器效率。

可预身份验证请求的授权模块将 IAuthenticationModule.CanPreAuthenticate 属性设置为 true

适用于