AuthenticationSection 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
為網頁應用程式設定認證。 此類別無法獲得繼承。
public ref class AuthenticationSection sealed : System::Configuration::ConfigurationSection
public sealed class AuthenticationSection : System.Configuration.ConfigurationSection
type AuthenticationSection = class
inherit ConfigurationSection
Public NotInheritable Class AuthenticationSection
Inherits ConfigurationSection
- 繼承
範例
這個範例示範如何使用這個 AuthenticationSection 類別。
// Get the Web application configuration.
System.Configuration.Configuration configuration =
WebConfigurationManager.OpenWebConfiguration(
"/aspnetTest");
// Get the authentication section.
AuthenticationSection authenticationSection =
(AuthenticationSection)configuration.GetSection(
"system.web/authentication");
' Get the Web application configuration.
Dim configuration _
As System.Configuration.Configuration = _
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration( _
"/aspnetTest")
' Get the section.
Dim authenticationSection _
As AuthenticationSection = _
CType(configuration.GetSection( _
"system.web/authentication"), AuthenticationSection)
警告
在 [credentials] 區段中儲存使用者認證 不安全。 請改用 Azure Key Vault。
備註
這個 AuthenticationSection 類別提供一種程式化的方式,可以存取並修改設定檔的該 authentication 區段。
Note
可以 AuthenticationSection 根據區段屬性所定義的限制,將資訊寫入設定檔的相關區段,該屬性 AllowDefinition 的值為 MachineToApplication。 任何嘗試在階層結構中不允許的層級寫入設定檔,解析器都會產生錯誤訊息。 不過,你可以用這個類別讀取階層中任何層級的設定資訊。 為了安全與可擴展性,建議使用外部資料庫來保存使用者的憑證。
建構函式
| 名稱 | Description |
|---|---|
| AuthenticationSection() |
初始化 AuthenticationSection 類別的新執行個體。 |