.NET Framework Class Library
MembershipProviderCollection Class

A collection of objects that inherit the MembershipProvider abstract class.

Namespace:  System.Web.Security
Assembly:  System.Web (in System.Web.dll)
Syntax

Visual Basic (Declaration)
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class MembershipProviderCollection _
    Inherits ProviderCollection
Visual Basic (Usage)
Dim instance As MembershipProviderCollection
C#
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class MembershipProviderCollection : ProviderCollection
Visual C++
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class MembershipProviderCollection sealed : public ProviderCollection
JScript
public final class MembershipProviderCollection extends ProviderCollection
Remarks

The membership providers for an application are exposed as a read-only MembershipProviderCollection by the Providers property of the Membership class. You can access a specific membership provider in the collection by name and cast it as the specific provider type, such as SqlMembershipProvider. 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.

NoteNote:

If you are not familiar with the membership features of ASP.NET, see Introduction to Membership before continuing. For a list of other topics related to membership, see Managing Users by Using Membership.

Examples

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

Visual Basic
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Configuration.Provider" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >
<head>
<title>List Enabled Providers</title>
</head>
<body>

<%
For Each p As ProviderBase In Membership.Providers
  Response.Write(p.Name & ", " & p.GetType().ToString() & "<br />")
Next
%>

</body>
</html>
C#
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Configuration.Provider" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >
<head>
<title>List Enabled Providers</title>
</head>
<body>

<%
foreach (ProviderBase p in Membership.Providers)
  Response.Write(p.Name + ", " + p.GetType() + "<br />");
%>

</body>
</html>
.NET Framework Security

Inheritance Hierarchy

System..::.Object
  System.Configuration.Provider..::.ProviderCollection
    System.Web.Security..::.MembershipProviderCollection
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0
See Also

Reference

Other Resources

Tags :


Page view tracker