语言

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则会引发异常。

适用于

另请参阅