次の方法で共有


add Element for properties for profile (ASP.NET Settings Schema)

Adds a property to the user profile.

This element is new in the .NET Framework version 2.0.

<add 
    name="property name" 
    type="fully qualified type reference"
    provider="provider name"
    serializeAs="String|Xml|Binary|ProviderSpecific"
    allowAnonymous="true|false"
    defaultValue="default property value"
    readOnly="true|false"
        customProviderData="data for a custom profile provider" />
/>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute Description

name

Required String attribute.

Specifies the name of the property. This value is used as the name of the property for the automatically generated profile class and as the index value for the property in the Properties collection. The name of the property cannot contain a period (.).

For more information about the automatic generation of user profile properties, see ASP.NET Profile Properties Overview.

type

Optional String attribute.

Specifies the type of the property.

The default is String.

provider

Optional String attribute.

Specifies the profile provider that is used to store and retrieve values for the property. The value of the provider attribute is the name of one of the profile providers that are specified in the providers element. If no provider name is specified, the default provider that is specified in the profile element is used. For more information about profile providers, see ASP.NET Profile Providers.

serializeAs

Optional SettingsSerializeAs attribute.

Specifies the serialization format for the property value in the data store. The default serialization format is specific to the provider specific. The actual serialization that is used is determined by the provider, which is String serialization in the case of the SQL provider.

allowAnonymous

Optional Boolean attribute.

Specifies whether the property can be get or set, if the application user is anonymous.

If set to true, the property can be get or set, if the application user is anonymous.

The default is false.

defaultValue

Optional String attribute.

Specifies the default value, if there is no value for the Profile property in the data store, as follows:

  • If the type of the property is serialized using XML serialization, this attribute can be set to an XML string that represents a serialized instance of the property type.

  • If the type of the property is serialized using binary serialization, this attribute can be set to a base-64 encoded string that represents a serialized instance of the property type.

  • If the property is a reference type, the String null value can be used to indicate that the Profile property should return null for noninitialized profiles.

readOnly

Optional Boolean attribute.

Specifies whether the property can be read, but not set.

If set to true, the property can be read, but not set.

The default is false.

customProviderData

Optional String attribute.

Specifies that the customProviderData attribute can be set to any string value to be used by the profile provider for the property. If this attribute is set, the value is placed in the Attributes collection for the property and is indexed by the name "CustomProviderData".

Child Elements

None.

Parent Elements

Element Description

configuration

Specifies the root element in every configuration file that is used by the common language runtime and the .NET Framework applications.

system.web

Specifies the root element for the ASP.NET configuration section.

profile

Configures the user profile for an application.

properties

Defines a collection of user profile properties and property groups.

Remarks

For information about accessing and modifying configuration values for the profile element in application code, see ProfileSection.

Example

The following example Web.config file demonstrates how to specify a user profile that contains a ZipCode property of type string and a RecentSearchList property of type StringCollection. The generated Profile property will have strongly typed accessors for each of the specified properties. For information about the user profile and an example of setting and reading user profile properties, see ASP.NET Profile Properties.

<configuration>
   <connectionStrings>
       <add name="SqlServices" connectionString="Data Source=localhost;Integrated Security=SSPI;Initial 
            Catalog=aspnetdb;" />
   </connectionStrings>

  <system.web>
   <anonymousIdentification enabled="true" />

   <profile defaultProvider="SqlProvider" >
     <providers>
       <add
         name="SqlProvider"
         connectionStringName="SqlServices"
         applicationName="HttpProfileBaseApplication"
         type="System.Web.Profile.SqlProfileProvider" />
     </providers>

     <properties>
       <add name="ZipCode" allowAnonymous="true" />
       <add name="RecentSearchList"
            type="System.Collections.Specialized.StringCollection"
            serializeAs="Xml"
            allowAnonymous="true" />
      </properties>
    </profile>
   </system.web>
</configuration>

Element Information

Configuration section handler

System.Web.Configuration.ProfileSection

Configuration member

System.Web.Configuration.SystemWebSectionGroup.Profile

Configurable locations

Machine.config

Root-level Web.config

Application-level Web.config

Requirements

Microsoft Internet Information Services (IIS) version 5.0, 5.1, or 6.0

The .NET Framework version 2.0

Microsoft Visual Studio 2005

See Also

Tasks

How to: Lock ASP.NET Configuration Settings

Reference

properties Element for profile (ASP.NET Settings Schema)
profile Element (ASP.NET Settings Schema)
system.web Element (ASP.NET Settings Schema)
<configuration> Element
clear Element for properties for profile (ASP.NET Settings Schema)
group Element for properties for profile (ASP.NET Settings Schema)
remove Element for properties for profile (ASP.NET Settings Schema)
ProfileSection
System.Configuration
System.Web.Configuration

Concepts

ASP.NET Configuration Overview
ASP.NET Web Server Controls and Browser Capabilities
Securing ASP.NET Configuration
ASP.NET Configuration Scenarios

Other Resources

ASP.NET Profile Properties
ASP.NET Configuration Files
ASP.NET Configuration Settings
General Configuration Settings (ASP.NET)
ASP.NET Configuration API