ProfileSection.PropertySettings Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Namespace:   System.Web.Configuration
Assembly:  System.Web (in System.Web.dll)

public RootProfilePropertySettingsCollection PropertySettings { get; }

Property Value

Type: System.Web.Configuration.RootProfilePropertySettingsCollection

A RootProfilePropertySettingsCollection object that contains all the properties defined within the properties subsection of the profile section of the configuration file.

The PropertySettings property is a RootProfilePropertySettingsCollection that provides a collection of ProfilePropertySettings objects and a collection of ProfileGroupSettings objects, each of which provides a named collection of other ProfilePropertySettings objects. These collections are used by the ASP.NET compilation engine to dynamically generate a class called ProfileCommon, which is derived from ProfileBase. The properties of the ProfileCommon class consist of the properties defined in the two collections. In addition, each group property of the ProfileCommon class will contain its own properties, as defined for that group.

The following code example shows how to use the PropertySettings property. This code example is part of a larger example provided for the ProfileSection class.

// Display all current root ProfilePropertySettings.
Console.WriteLine("Current Root ProfilePropertySettings:");
int rootPPSCtr = 0;
foreach (ProfilePropertySettings rootPPS in profileSection.PropertySettings)
    Console.WriteLine("  {0}: ProfilePropertySetting '{1}'", ++rootPPSCtr,

// Get and modify a root ProfilePropertySettings object.
    "Display and modify 'LastReadDate' ProfilePropertySettings:");
ProfilePropertySettings profilePropertySettings =

// Get the current ReadOnly property value.
    "Current ReadOnly value: '{0}'", profilePropertySettings.ReadOnly);

// Set the ReadOnly property to true.
profilePropertySettings.ReadOnly = true;

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

// Set the AllowAnonymous property to true.
profilePropertySettings.AllowAnonymous = true;

// Get the current SerializeAs property value.
    "Current SerializeAs value: '{0}'", profilePropertySettings.SerializeAs);

// Set the SerializeAs property to SerializationMode.Binary.
profilePropertySettings.SerializeAs = SerializationMode.Binary;

// Get the current Type property value.
    "Current Type value: '{0}'", profilePropertySettings.Type);

// Set the Type property to "System.DateTime".
profilePropertySettings.Type = "System.DateTime";

// Get the current DefaultValue property value.
    "Current DefaultValue value: '{0}'", profilePropertySettings.DefaultValue);

// Set the DefaultValue property to "March 16, 2004".
profilePropertySettings.DefaultValue = "March 16, 2004";

// Get the current ProviderName property value.
    "Current ProviderName value: '{0}'", profilePropertySettings.Provider);

// Set the ProviderName property to "AspNetSqlRoleProvider".
profilePropertySettings.Provider = "AspNetSqlRoleProvider";

// Get the current Name property value.
    "Current Name value: '{0}'", profilePropertySettings.Name);

// Set the Name property to "LastAccessDate".
profilePropertySettings.Name = "LastAccessDate";

// Display all current ProfileGroupSettings.
Console.WriteLine("Current ProfileGroupSettings:");
int PGSCtr = 0;
foreach (ProfileGroupSettings propGroups in profileSection.PropertySettings.GroupSettings)
    Console.WriteLine("  {0}: ProfileGroupSetting '{1}'", ++PGSCtr,
    int PPSCtr = 0;
    foreach (ProfilePropertySettings props in propGroups.PropertySettings)
        Console.WriteLine("    {0}: ProfilePropertySetting '{1}'", ++PPSCtr,

// Add a new group.
ProfileGroupSettings newPropGroup = new ProfileGroupSettings("Forum");

// Add a new PropertySettings to the group.
ProfilePropertySettings newProp = new ProfilePropertySettings("AvatarImage");
newProp.Type = "System.String, System.dll";

// Remove a PropertySettings from the group.

// Clear all PropertySettings from the group.

.NET Framework
Available since 2.0
Return to top