Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Membership.Providers Property

Gets a collection of the membership providers for the ASP.NET application.

Namespace:  System.Web.Security
Assembly:  System.Web (in System.Web.dll)
static member Providers : MembershipProviderCollection

Property Value

Type: System.Web.Security.MembershipProviderCollection
A MembershipProviderCollection of the membership providers configured for the ASP.NET application.

The Providers property references all of the membership providers enabled for an application, including providers added in the Web.config file for the application and the Machine.config file for all applications. You can control which membership providers are available for an application using the providers element of the membership section in the configuration for your application. For example, the following sample shows the membership section in the Web.config file for an application that removes the SqlMembershipProvider instance (AspNetSqlProvider) specified in the machine configuration file and adds a SqlMembershipProvider instance named SqlProvider as the default membership provider for the application.

<configuration>
  <connectionStrings>
    <add name="SqlServices" connectionString="Data Source=MySqlServer;Integrated Security=SSPI;Initial Catalog=aspnetdb;" />
  </connectionStrings>
  <system.web>
    <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="20">
      <providers>
        <remove name="AspNetSqlProvider" />
          <add name="SqlProvider"
            type="System.Web.Security.SqlMembershipProvider"
            connectionStringName="SqlServices"
            enablePasswordRetrieval="false"
            enablePasswordReset="true"
            requiresQuestionAndAnswer="true"
            passwordFormat="Hashed"
            applicationName="/" />
      </providers>
    </membership>
  </system.web>
</configuration>

When specifying the membership Element (ASP.NET Settings Schema) section, you must specify the defaultProvider attribute. If you do not specify a membership Element (ASP.NET Settings Schema) section in your Web.config, the values from the machine configuration are used and the SqlMembershipProvider instance named AspNetSqlProvider is established as the defaultProvider.

You can obtain a strongly typed reference to a provider from the Providers collection by indexing the membership provider by name and casting it as the desired type.

The following code example lists the providers enabled for an application and their respective types.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.