HttpWebRequest.PreAuthenticate 屬性

定義

取得或設定值,指出是否隨著要求傳送授權標頭。

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

屬性值

true 表示在驗證發生之後傳送具有要求的 HTTP 授權標頭;否則為 false 。 預設值為 false

備註

成功驗證對特定 Uri 要求的用戶端要求之後,如果 PreAuthenticate 提供 和 true 認證,則會將授權標頭與每個要求一起傳送至符合 Uri 最後一個正斜線之特定 Uri 的任何要求。 因此,如果用戶端要求已成功向包含下列專案的特定 Uri 驗證:

http://www.contoso.com/firstpath/

然後,預先驗證的授權標頭會隨著每個要求傳送至下列 Uri 任何一個實例:

http://www.contoso.com/firstpath/

http://www.contoso.com/firstpath/default

http://www.contoso.com/firstpath/default.html

http://www.contoso.com/firstpath/sample.html

不過,授權標頭不會隨著要求傳送至下列 Uri 任何實例:

http://www.contoso.com/

http://www.contoso.com/firstpath

http://www.contoso.com/secondpath/

http://www.contoso.com/firstpath/thirdpath/

如果對特定 Uri 要求的用戶端要求未成功驗證,則要求會使用標準驗證程式。

除了第一個要求之外, PreAuthenticate 屬性會指出是否要將驗證資訊與後續要求傳送至 Uri 符合最後一個正斜線的特定 Uri ,而不需要等候伺服器挑戰。

用戶端與伺服器之間的下列對話方塊說明此屬性的效果。 對話方塊假設基本驗證正在使用中。

PreAuthenticatefalse

用戶端:GET someUrl

伺服器:401 WWW-Authenticate Basic

用戶端:具有授權標頭的 GET

伺服器:200 確定

用戶端:GET someUrl

伺服器:401 WWW-Authenticate Basic

用戶端:具有授權標頭的 GET

伺服器:200 確定

PreAuthenticatetrue

用戶端:GET someUrl

伺服器:401 WWW-Authenticate Basic

用戶端:具有授權標頭的 GET

伺服器:200 確定

用戶端:具有授權標頭的 GET someUrl

如果驗證配置不支援預先驗證,則會忽略此屬性的值。

適用於