語言

ProfilePropertySettings.AllowAnonymous 屬性

定義

會取得或設定一個值,表示動態產生 ProfileCommon 類別中相關屬性是否能由匿名使用者設定。

public:
 property bool AllowAnonymous { bool get(); void set(bool value); };
[System.Configuration.ConfigurationProperty("allowAnonymous", DefaultValue=false)]
public bool AllowAnonymous { get; set; }
[<System.Configuration.ConfigurationProperty("allowAnonymous", DefaultValue=false)>]
member this.AllowAnonymous : bool with get, set
Public Property AllowAnonymous As Boolean

屬性值

true 如果類別中 ProfileCommon 相關的屬性可以由匿名使用者設定;否則, false表示匿名使用者無法更改屬性值。 預設值為 false。

屬性

範例

以下程式碼範例說明如何使用該 AllowAnonymous 屬性。 此程式碼範例是本類別更大範例 ProfileSection 的一部分。

// Get the current AllowAnonymous property value.
Console.WriteLine(
    "Current AllowAnonymous value: '{0}'", profilePropertySettings.AllowAnonymous);

// Set the AllowAnonymous property to true.
profilePropertySettings.AllowAnonymous = true;
' Get the current AllowAnonymous property value.
Console.WriteLine( _
    "Current AllowAnonymous value: '{0}'", profilePropertySettings.AllowAnonymous)

' Set the AllowAnonymous property to true.
profilePropertySettings.AllowAnonymous = true

備註

執行時,ASP.NET 編譯系統會根據設定檔區段中指定的 profile 資訊產生一個稱為 ProfileCommon的類別,該類別由 衍生而 ProfileBase來。 這個類別允許你存取並修改個別使用者設定檔的數值。

ProfileCommon類別定義基於設定檔該properties節子節中定義profile的屬性。 你為類別實例 ProfilePropertySettings 指定的屬性值,將用來定義類別中 ProfileCommon 相關的屬性。

若類別中的ProfileCommon屬性在屬性值為 AllowAnonymous時被匿名使用者false更改,則會拋出例外。

適用於

另請參閱