AuthenticationManager.PreAuthenticate(WebRequest, ICredentials) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
警告
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
對因特網資源的要求。
- credentials
- ICredentials
與要求相關聯的認證。
傳回
如果可以預先驗證要求,則為 Authorization 類別的執行個體,否則為 null
。 如果 credentials
為 null
,這個方法會傳回 null
。
- 屬性
例外狀況
僅限 .NET Core 與 .NET 5+:在所有情況下。
request
為 null
。
備註
如果驗證模組可以預先驗證要求,此方法會傳回驗證實例, PreAuthenticate 並將授權資訊預先傳送至伺服器,而不是等待資源發出挑戰。 此行為概述於 RFC 2617 (HTTP 驗證:基本和摘要式存取驗證) 一節 3.3。 支援預先驗證的驗證模組可讓用戶端避免驗證挑戰所造成的額外往返,以改善伺服器效率。
預先驗證要求的授權模組會將 IAuthenticationModule.CanPreAuthenticate 屬性設定為 true
。