Share via


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

Adds a profile provider instance to the user profile provider collection.

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

<add 
    name="provider name" 
    type="fully qualified type reference"
    connectionStringName="connection string identifier"
    commandTimeout="number of seconds before a command times out"
    description="description of the provider instance"
    applicationName="application name for stored profile information" />

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 provider instance. This is the value that is used for the defaultProvider attribute of the <profile> element to identify the provider instance as the default profile provider. The name of the provider is also used to index the provider in the Providers collection.

type

Required String attribute.

Specifies the type that is implementing the ProfileProvider abstract base class.

connectionStringName

Required String attribute.

Specifies the name of a connection string that is defined in the <connectionStrings> element. The specified connection string will be used by the provider being added.

applicationName

Optional String attribute.

Specifies the name of the application under which profile data is stored at the data source. The application name enables multiple ASP.NET applications to use the same database without encountering duplicate profile data for different applications. Alternatively, multiple ASP.NET applications can use the same profile information by specifying the same application name.

The profile providers that are included with the .NET Framework use the ApplicationVirtualPath value for the ApplicationName property, if this attribute is not specified.

commandTimeout

Optional Int32 attribute.

Specifies the number of seconds before a command that is issued to the membership data source times out. This time-out is used by the SQL provider when it creates SqlCommand objects. By default, this attribute is not set in the ASP.NET configuration. Therefore the ADO.NET default of 30 seconds is used. If this attribute is set, the SQL provider uses the configured time-out value for all SQL commands that are issued to the database.

The default is 30 (the ADO.NET default).

description

Optional String attribute.

Specifies a description of the profile provider instance.

Child Elements

None.

Parent Elements

Element Description

providers

Defines a collection of profile providers for the user profile.

profile

Configures the user profile for an application.

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.

Remarks

You can include additional attributes in the add element for a custom profile provider implementation. For an example, see How to: Build and Run the Profile Provider Example.

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

Default Configuration

The following default profile element is configured in the Machine.config file in the .NET Framework version 2.0.

  <providers>
    <add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
  </providers> 

Example

The following code example shows how to create a Web.config file for an ASP.NET application that is configured to use a SqlProfileProvider provider.

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

  <system.web>
    <authentication mode="Forms" >
      <forms loginUrl="login.aspx" name=".ASPXFORMSAUTH" />
    </authentication>

    <authorization>
      <deny users="?" />
    </authorization>

    <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
      <providers>
        <clear/>
        <add name="SqlProvider" 
             type="System.Web.Security.SqlMembershipProvider" 
             connectionStringName="SqlServices"
             applicationName="SampleApplication"
             enablePasswordRetrieval="true"
             enablePasswordReset="true"
             passwordFormat="Encrypted"
             requiresQuestionAndAnswer="true" />
      </providers>
    </membership>

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

      <properties>
        <add name="ZipCode" />
        <add name="CityAndState" />
      </properties>
    </profile>
  </system.web>
</configuration>

Element Information

Configuration section handler

System.Web.Configuration.ProfileSection

Configuration Member

System.Web.Configuration.ProfileSection.Providers

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

profile Element (ASP.NET Settings Schema)
system.web Element (ASP.NET Settings Schema)
<configuration> Element
remove Element for providers for profile (ASP.NET Settings Schema)
clear Element for providers 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