ProfileManager.Providers Propriedade
Definição
Obtém uma coleção de provedores de criação de perfil para o aplicativo ASP.NET.Gets a collection of the profile providers for the ASP.NET application.
public:
static property System::Web::Profile::ProfileProviderCollection ^ Providers { System::Web::Profile::ProfileProviderCollection ^ get(); };
public static System.Web.Profile.ProfileProviderCollection Providers { get; }
member this.Providers : System.Web.Profile.ProfileProviderCollection
Public Shared ReadOnly Property Providers As ProfileProviderCollection
Valor da propriedade
Um ProfileProviderCollection dos provedores de perfil configurados para o aplicativo ASP.net.A ProfileProviderCollection of the profile providers configured for the ASP.NET application.
Exceções
Foi feita uma tentativa de obter o valor da propriedade Providers sem pelo menos a permissão Medium.An attempt was made to get the Providers property value without at least Medium permission.
Exemplos
O exemplo de código a seguir lista os provedores habilitados para um aplicativo e seus respectivos tipos.The following code example lists the providers enabled for an application and their respective types.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Profile" %>
<%@ 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 xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>List Enabled Providers</title>
</head>
<body>
<%
foreach (ProviderBase p in ProfileManager.Providers)
Response.Write(p.Name + ", " + p.GetType() + "<br />");
%>
</body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Profile" %>
<%@ 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 xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>List Enabled Providers</title>
</head>
<body>
<%
For Each p As ProviderBase In ProfileManager.Providers
Response.Write(p.Name & ", " & p.GetType().ToString() & "<br />")
Next
%>
</body>
</html>
Comentários
A Providers propriedade faz referência a todos os provedores de perfil habilitados para um aplicativo, incluindo provedores adicionados na configuração do computador e provedores adicionados em todos os arquivos de Web.config.The Providers property references all of the profile providers enabled for an application, including providers added in the machine configuration and providers added in all Web.config files. Você pode controlar quais provedores de perfil estão disponíveis para um aplicativo usando o elemento Providers da seção Profile no arquivo de configuração.You can control which profile providers are available for an application using the providers element of the profile section in the configuration file. Por exemplo, o arquivo Web.config a seguir remove os provedores de perfil especificados nos arquivos de configuração pai e adiciona uma SqlProfileProvider instância como o provedor de perfil para o aplicativo.For example, the following Web.config file removes the profile providers specified in parent configuration files and adds a SqlProfileProvider instance as the profile provider for the application.
<configuration>
<connectionStrings>
<add name="SqlServices" connectionString=
"Data Source=MySqlServer;Integrated Security=SSPI;Initial Catalog=aspnetdb;" />
</connectionStrings>
<system.web>
<profile enabled="true" defaultProvider="SqlProvider">
<providers>
<clear />
<add name="SqlProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="SqlServices"
applicationName="MyApplication" />
</providers>
</profile>
</system.web>
</configuration>
Ao especificar a seção de perfil , você deve especificar um provedor padrão definindo o defaultProvider atributo.When specifying the profile section, you must specify a default provider by setting the defaultProvider attribute. Se você não especificar uma seção no arquivo de Web.config, os valores da configuração da máquina serão usados e a SqlProfileProvider instância chamada AspNetSqlProvider será estabelecida como o provedor padrão.If you do not specify a section in your Web.config file, the values from the machine configuration are used and the SqlProfileProvider instance named AspNetSqlProvider is established as the default provider.
Você pode obter uma referência fortemente tipada a um provedor da Providers coleção indexando o provedor de perfil por nome e convertendo-o como o tipo desejado.You can obtain a strongly typed reference to a provider from the Providers collection by indexing the profile provider by name and casting it as the desired type.