FormsAuthenticationConfiguration 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
配置 ASP.NET 應用程式以使用 AuthenticationMode forms 模態。
public ref class FormsAuthenticationConfiguration sealed : System::Configuration::ConfigurationElement
public sealed class FormsAuthenticationConfiguration : System.Configuration.ConfigurationElement
type FormsAuthenticationConfiguration = class
inherit ConfigurationElement
Public NotInheritable Class FormsAuthenticationConfiguration
Inherits ConfigurationElement
- 繼承
範例
以下程式碼範例說明如何從現有網頁應用程式的設定檔取得該 FormsAuthenticationConfiguration 物件。 你可以用這個物件存取它的成員。
// Get the Web application configuration.
System.Configuration.Configuration configuration =
WebConfigurationManager.OpenWebConfiguration("/aspnetTest");
// Get the external Authentication section.
AuthenticationSection authenticationSection =
(AuthenticationSection)configuration.GetSection(
"system.web/authentication");
// Get the external Forms section .
FormsAuthenticationConfiguration formsAuthentication =
authenticationSection.Forms;
' Get the Web application configuration.
Dim configuration As System.Configuration.Configuration =
WebConfigurationManager.OpenWebConfiguration(
"/aspnetTest")
' Get the external Authentication section.
Dim authenticationSection _
As AuthenticationSection =
CType(configuration.GetSection(
"system.web/authentication"), AuthenticationSection)
' Get the external Forms section .
Dim formsAuthentication _
As FormsAuthenticationConfiguration =
authenticationSection.Forms
備註
這個 FormsAuthenticationConfiguration 類別提供了一種程式化的方式,可以存取並修改 forms 設定 authentication 區段的元素。
此類型屬於包含 FormsAuthenticationCredentials、 FormsAuthenticationUserCollection、 和 FormsAuthenticationUser 類型的群組。 集合類型以外的類型直接影響底層的配置標籤。
警告
在 [credentials] 區段中儲存使用者認證 不安全。 請改用 Azure Key Vault。
Note
可以 FormsAuthenticationConfiguration 根據區段屬性所定義的限制,將資訊寫入設定檔的相關區段,該屬性 AllowDefinition 的值為 MachineToApplication。 任何嘗試在階層結構中不允許的層級寫入設定檔,解析器都會產生錯誤訊息。 不過,你可以用這個類別讀取階層中任何層級的設定資訊。 為了安全性與可擴展性,建議使用 Azure Key Vault來儲存使用者憑證。
建構函式
| 名稱 | Description |
|---|---|
| FormsAuthenticationConfiguration() |
初始化 FormsAuthenticationConfiguration 類別的新執行個體。 |