ProfileManager.Providers 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
ASP.NET 애플리케이션에 대한 프로필 공급자의 컬렉션을 가져옵니다.
public:
static property System::Web::Profile::ProfileProviderCollection ^ Providers { System::Web::Profile::ProfileProviderCollection ^ get(); };
public static System.Web.Profile.ProfileProviderCollection Providers { get; }
static member Providers : System.Web.Profile.ProfileProviderCollection
Public Shared ReadOnly Property Providers As ProfileProviderCollection
속성 값
ASP.NET 애플리케이션에 대해 구성된 프로필 공급자 중 한 ProfileProviderCollection 입니다.
예외
예제
다음 코드 예제에서는 애플리케이션 및 해당 형식에 대해 사용하도록 설정된 공급자를 나열합니다.
<%@ 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>
설명
이 속성은 Providers 컴퓨터 구성에 추가된 공급자 및 모든 Web.config 파일에 추가된 공급자를 포함하여 애플리케이션에 대해 사용하도록 설정된 모든 프로필 공급자를 참조합니다. 구성 파일에서 프로필 섹션의 공급자 요소를 사용하여 애플리케이션에 사용할 수 있는 프로필공급자를 제어할 수 있습니다. 예를 들어 다음 Web.config 파일은 부모 구성 파일에 지정된 프로필 공급자를 제거하고 애플리케이션에 대한 프로필 공급자로 인스턴스를 추가합니다 SqlProfileProvider .
<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>
프로필 섹션을 지정할 때 특성을 설정하여 기본 공급자를 defaultProvider 지정해야 합니다. Web.config 파일에 섹션을 profile 지정하지 않으면 컴퓨터 구성의 값이 사용되고 SqlProfileProvider AspNetSqlProvider라는 인스턴스가 기본 공급자로 설정됩니다.
이름으로 프로필 공급자를 인덱싱하고 원하는 형식으로 캐스팅하여 컬렉션에서 Providers 공급자에 대한 강력한 형식의 참조를 얻을 수 있습니다.