MembershipProviderCollection.Item[String] 属性

定义

获取集合中由指定的提供程序名称引用的成员资格提供程序。Gets the membership provider in the collection referenced by the specified provider name.

public:
 property System::Web::Security::MembershipProvider ^ default[System::String ^] { System::Web::Security::MembershipProvider ^ get(System::String ^ name); };
public System.Web.Security.MembershipProvider this[string name] { get; }
member this.Item(string) : System.Web.Security.MembershipProvider
Default Public ReadOnly Property Item(name As String) As MembershipProvider

参数

name
String

成员资格提供程序的名称。The name of the membership provider.

属性值

继承 MembershipProvider 抽象类的对象。An object that inherits the MembershipProvider abstract class.

示例

下面的代码示例按名称SqlMembershipProvider ProvidersMembership类的属性访问为应用程序配置的。The following code example accesses a SqlMembershipProvider configured for an application from the Providers property of the Membership class by name.

SqlMembershipProvider p = (SqlMembershipProvider)Membership.Providers["SqlProvider"];
PasswordFormatLabel.Text = p.PasswordFormat.ToString();
Dim p As SqlMembershipProvider = CType(Membership.Providers("SqlProvider"), SqlMembershipProvider)
PasswordFormatLabel.Text = p.PasswordFormat.ToString()

注解

应用程序的成员资格提供程序是MembershipProviderCollection ProvidersMembership类的属性以只读方式公开的。The membership providers for an application are exposed as a read-only MembershipProviderCollection by the Providers property of the Membership class. 您可以按名称访问集合中的特定成员资格提供程序, 并将其转换为特定的提供程序SqlMembershipProvider类型 (如)。You can access a specific membership provider in the collection by name and cast it as the specific provider type, such as SqlMembershipProvider. 这使您可以在单个应用程序中管理多个数据存储区中的成员身份信息, 以及访问不属于MembershipProvider抽象类的成员资格提供程序的自定义成员。This enables you to manage membership information from multiple data stores in a single application as well as access custom members of a membership provider that are not part of the MembershipProvider abstract class.

适用于

另请参阅