<authentication> 項目
設定 ASP.NET 驗證支援。只可以在電腦、網站或應用程式層級宣告這個項目。如果嘗試在子目錄或頁面層級的任何組態檔中宣告這個項目,會造成剖析器錯誤訊息。
<configuration>
<system.web>
<authentication>
<authentication mode="Windows|Forms|Passport|None">
<forms name="name"
loginUrl="url"
protection="All|None|Encryption|Validation"
timeout="30" path="/" >
requireSSL="true|false"
slidingExpiration="true|false">
<credentials passwordFormat="Clear|SHA1|MD5">
<user name="username" password="password"/>
</credentials>
</forms>
<passport redirectUrl="internal"/>
</authentication>
必要屬性
屬性 | 選項 | 說明 |
---|---|---|
mode | 控制應用程式的預設驗證模式。 | |
Windows | 指定 Windows 驗證作為預設驗證模式。當使用任何形式的 Internet Information Services (IIS) 驗證:基本、摘要、整合式 Windows 驗證 (NTLM/Kerberos) 或認證時,使用這個模式。 | |
Forms | 指定 ASP.NET 表單式驗證作為預設驗證模式。 | |
Passport | 指定 Microsoft Passport 驗證作為預設驗證模式。 | |
None | 不指定驗證。僅在期待匿名使用者或應用程式可處理事件以提供它們自己的驗證時才使用。 |
子標記
子標記 | 說明 |
---|---|
<forms> | 設定 ASP.NET 應用程式以進行自訂表單架構驗證。 |
<passport> | 指定如果網頁需要驗證且使用者尚未使用 Passport 簽入時要重新導向的網頁。 |
範例
下列範例設定網站進行表單式驗證,指定從用戶端傳輸登入資訊的 Cookie 名稱,以及指定初始驗證失敗時要使用的登入網頁名稱。您需要包含 <authorization> 區段,以要求所有使用者提供表單驗證,並拒絕匿名使用者存取網站。
<configuration>
<system.web>
<authentication mode="Forms">
<forms name="401kApp" loginUrl="/login.aspx"/>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</configuration>
需求
包含於:<system.web>
**Web 平台:**IIS 5.0、IIS 5.1、IIS 6.0
**組態檔:**Machine.config, Web.config
**組態區段處理常式:**System.Web.Configuration.AuthenticationConfigHandler