ProfileProviderAttribute クラス
アセンブリ: System.Web (system.web.dll 内)

<AttributeUsageAttribute(AttributeTargets.Property)> _ Public NotInheritable Class ProfileProviderAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Property)] public sealed class ProfileProviderAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Property)] public ref class ProfileProviderAttribute sealed : public Attribute

カスタム プロファイルの実装で使用するプロパティのプロファイル プロバイダを識別するには、ProfileProviderAttribute クラスが使用されます。カスタム プロファイルの実装は ProfileBase 抽象クラスから継承したクラスであり、profile 構成要素で指定されていないユーザー プロファイルのプロパティを定義します。ユーザー プロファイルのカスタム型は、次の例に示すように、アプリケーションの Web.config ファイルにある profile 構成要素の inherits 属性を使用して指定できます。
<connectionStrings>
<add name="SqlServices" connectionString=
"Data Source=localhost;Integrated Security=SSPI;Initial Catalog=aspnetdb;" />
</connectionStrings>
<authentication mode="Forms" >
<forms loginUrl="login.aspx"
name=".ASPXFORMSAUTH" />
</authentication>
</authorization>
<profile inherits="Samples.AspNet.Profile.EmployeeProfile"
defaultProvider="SqlProvider">
<providers>
<clear />
<add
name="SqlProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="SqlServices"
description="SQL Profile Provider for Sample"/>
<add
name="EmployeeInfoProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="SqlServices"
description="SQL Profile Provider for Employee Info"/>
</providers>
</properties>
</profile>
</system.web>
</configuration>

ProfileBase クラスから継承するクラスを定義して、カスタム プロファイルを作成するコード例を次に示します。カスタム プロファイルの型は、アプリケーションの Web.config ファイルにある profile 構成要素の inherits 属性を使用して指定します。
Imports System Imports System.Web.Profile Namespace Samples.AspNet.Profile Public Class EmployeeProfile Inherits ProfileBase <SettingsAllowAnonymous(False)> _ <ProfileProvider("EmployeeInfoProvider")> _ Public Property Department As String Get Return MyBase.Item("EmployeeDepartment").ToString() End Get Set MyBase.Item("EmployeeDepartment") = value End Set End Property <SettingsAllowAnonymous(False)> _ <ProfileProvider("EmployeeInfoProvider")> _ Public Property Details As EmployeeInfo Get Return CType(MyBase.Item("EmployeeInfo"), EmployeeInfo) End Get Set MyBase.Item("EmployeeInfo") = value End Set End Property End Class Public Class EmployeeInfo Public Name As String Public Address As String Public Phone As String Public EmergencyContactName As String Public EmergencyContactAddress As String Public EmergencyContactPhone As String End Class End Namespace
using System; using System.Web.Profile; namespace Samples.AspNet.Profile { public class EmployeeProfile : ProfileBase { [SettingsAllowAnonymous(false)] [ProfileProvider("EmployeeInfoProvider")] public string Department { get { return base["EmployeeDepartment"].ToString(); } set { base["EmployeeDepartment"] = value; } } [SettingsAllowAnonymous(false)] [ProfileProvider("EmployeeInfoProvider")] public EmployeeInfo Details { get { return (EmployeeInfo)base["EmployeeInfo"]; } set { base["EmployeeInfo"] = value; } } } public class EmployeeInfo { public string Name; public string Address; public string Phone; public string EmergencyContactName; public string EmergencyContactAddress; public string EmergencyContactPhone; } }


System.Attribute
System.Web.Profile.ProfileProviderAttribute


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- ProfileProviderAttribute クラスのページへのリンク